根据 Windows 版本在 Inno Setup 运行 部分执行不同的命令

Execute different command in Inno Setup Run section based on Windows version

我需要知道 Windows 是 XP、7、8、2003、2008 还是 2012,因为取决于版本我会 运行 一个特定的命令。

我尝试在 Windows 2008 中安装 IIS,但没有成功。我在 Windows 2012 年尝试过,它工作正常。

Filename: pkgmgr; Parameters: "/iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-HttpRedirect;IIS-ApplicationDevelopment;IIS-ASPNET;IIS-NetFxExtensibility;IIS-ASP;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-ServerSideIncludes;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-Security;IIS-BasicAuthentication;IIS-ManagementService;IIS-CGI;IIS-RequestFiltering;IIS-Performance;IIS-ManagementConsole;IIS-WindowsAuthentication;IIS-WebServer;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI;IIS-ASPNET;NetFx4Extended-ASPNET45;IIS-ASPNET45;IIS-NetFxExtensibility45;NetFx4Extended-ASPNET45"; Flags: 64bit; Check: IsWin64

我不得不 运行 在 Windows 2008 年手动执行此操作:

start /w pkgmgr /l:log.etw /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-ManagementService;IIS-CGI;IIS-RequestFiltering;IIS-ASPNET;IIS-HttpLogging;IIS-NetFxExtensibility;IIS-HttpErrors;IIS-DefaultDocument;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-StaticContent;IIS-ManagementConsole;IIS-DirectoryBrowsing;IIS-WindowsAuthentication;IIS-WebServer;

使用MinVersion and OnlyBelowVersion parameters in the [Run] section:

[Run]
; for Windows 2012 and newer:
Filename: pkgmgr; Parameters: "/iu:..."; MinVersion: 6.2
; for older versions (Windows 2008)
Filename: pkgmgr; Parameters: "/iu:..."; OnlyBelowVersion: 6.2

学习the Windows version numbers.