1

我正在尝试以编程方式安装 IIS7+。如果我直接在 cmd 提示符下运行它,它运行良好。

start /w pkgmgr /l:log.etw /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-CGI;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-ServerSideIncludes;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-Security;IIS-BasicAuthentication;IIS-URLAuthorization;IIS-RequestFiltering;IIS-IPSecurity;IIS-Performance;IIS-HttpCompressionStatic;IIS-HttpCompressionDynamic;IIS-WebServerManagementTools;IIS-ManagementConsole;IIS-ManagementScriptingTools;IIS-ManagementService;IIS-IIS6ManagementCompatibility;IIS-Metabase;IIS-WMICompatibility;IIS-LegacyScripts;IIS-LegacySnapIn;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI

由于开头的“开始”部分,我对如何运行 ServiceProcess.Process 类有点困惑。我可以运行我需要的任何其他 exe,但 pkgmgr.exe 并不能很好地运行。

Using proc As New Process()
    proc.StartInfo.FileName = "c:\windows\system32\pkgmgr.exe"
    proc.StartInfo.Arguments = "/l:log.etw /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-CGI;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-ServerSideIncludes;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-Security;IIS-BasicAuthentication;IIS-URLAuthorization;IIS-RequestFiltering;IIS-IPSecurity;IIS-Performance;IIS-HttpCompressionStatic;IIS-HttpCompressionDynamic;IIS-WebServerManagementTools;IIS-ManagementConsole;IIS-ManagementScriptingTools;IIS-ManagementService;IIS-IIS6ManagementCompatibility;IIS-Metabase;IIS-WMICompatibility;IIS-LegacyScripts;IIS-LegacySnapIn;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI"
    proc.Start()
    proc.WaitForExit()
End Using
4

1 回答 1

1

我发现这个值得信赖的链接Using Unattended Setup to Install IIS 7.0

第 1 步:PKGMGR.EXE 概述

Windows Vista/Windows Server 2008 中的可选功能是使用名为 Pkgmgr 的新命令工具安装的。使用 pkgmgr.exe 的命令行语法是:

Start /w pkgmgr.exe /iu:update1;update2… 

Pkgmgr.exe 命令

/iu:{更新名称}; 这指定要按更新名称安装的更新,并采用分号分隔的要安装的更新名称。

/uu:{更新名称}; 这指定要卸载的更新,并采用分号分隔的要从系统卸载的可选更新列表。必须至少指定一个更新名称

/n:{unattend XML} 这指定了无人参与 XML 文件的文件名。

有关 XML 文件的更多详细信息,请参阅 MSDN 文章。


例如:

要仅安装 IIS 7.0 默认功能,请将以下 unattend.xml 文本复制到记事本中。

<?xml version="1.0" ?> 
<unattend xmlns="urn:schemas-microsoft-com:unattend"  
    xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">
<servicing> 
   <!-- Install a selectable update in a package that is in the Windows Foundation namespace --> 
   <package action="configure"> 
      <ssemblyIdentity 
         name="Microsoft-Windows-Foundation-Package"
         version="6.0.5308.6"
         language="neutral"
         processorArchitecture="x86"
         publicKeyToken="31bf3856ad364e35"
         versionScope="nonSxS"
      />
    <selection name="IIS-WebServerRole" state="true"/> 
    <selection name="WAS-WindowsActivationService" state="true"/> 
    <selection name="WAS-ProcessModel" state="true"/> 
    <selection name="WAS-NetFxEnvironment" state="true"/> 
    <selection name="WAS-ConfigurationAPI" state="true"/> 
  </package> 
</servicing> 
</unattend> 
于 2013-04-19T04:16:15.267 回答