在 64 位计算机上使用 32 位应用程序从 C# 代码安装 IIS
我正在尝试在 64 位计算机上安装 IIS。 安装的是 32 位 C# 应用程序。
代码如下(取自此处):
Process proc = new Process();
string cmd = @"C:\Windows\System32\pkgmgr.exe";
string cmdargument =
@" start /w pkgmgr /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-HealthAndDiagnostics;IIS-HttpLogging;
IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-Security;IIS-WindowsAuthentication;
IIS-RequestFiltering;IIS-IPSecurity;IIS-Performance;IIS-HttpCompressionStatic;IIS-WebServerManagementTools;
IIS-ManagementConsole;IIS-ManagementScriptingTools;IIS-ManagementService;WAS-WindowsActivationService;
WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI;NetFx3";
proc = Process.Start(cmd, cmdargument);
proc.WaitForExit();
proc.Close();
编译应用程序时对于“AnyCPU”,一切正常。 但它是用“x86”编译的,PkgMgr 窗口显示错误:“尝试加载格式不正确的程序”。
我还尝试从 wow32 文件夹运行 PkgMgr,但效果不佳。
有什么想法吗?谢谢。
I'm trying to install IIS on a 64bit machine.
The installation is a 32bit c# application.
The code is as follows (taken from here):
Process proc = new Process();
string cmd = @"C:\Windows\System32\pkgmgr.exe";
string cmdargument =
@" start /w pkgmgr /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-HealthAndDiagnostics;IIS-HttpLogging;
IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-Security;IIS-WindowsAuthentication;
IIS-RequestFiltering;IIS-IPSecurity;IIS-Performance;IIS-HttpCompressionStatic;IIS-WebServerManagementTools;
IIS-ManagementConsole;IIS-ManagementScriptingTools;IIS-ManagementService;WAS-WindowsActivationService;
WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI;NetFx3";
proc = Process.Start(cmd, cmdargument);
proc.WaitForExit();
proc.Close();
When the application is compiled to "AnyCPU" everything works fine.
But it is compiled with "x86" the PkgMgr window shows an error: "An attempt was made to load a program with an incorrect format".
I also tried to run the PkgMgr from the wow32 folder but it didn't work as well.
Any idea? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我找到了一个解决方案,它不是最佳的,但它有效。
我用 AnyCPU 编译包装 PkgMgr 执行并完成工作。
我还是想找到一个更“正确”的解决方案。
I think I found a solution, it is not optimal but it works.
I'm wrapping the PkgMgr execution with an AnyCPU compilation and does the work.
I still would like to find a more "right" solution.