Installing IIS from c# code on 64bit machine with 32bit application
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;II开发者_开发百科S-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.
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.
精彩评论