我得到了一个批处理文件,其中包含:
start /w dism /online /enable-feature /featurename:IIS-WebServerRole
start /w dism /online /enable-feature /featurename:IIS-WebServer
start /w dism /online /enable-feature /featurename:IIS-IIS6ManagementCompatibility
start /w dism /online /enable-feature /featurename:IIS-Metabase
start /w dism /online /enable-feature /featurename:IIS-ManagementService
start /w dism /online /enable-feature /featurename:IIS-HttpRedirect
start /w dism /online /enable-feature /featurename:IIS-RequestMonitor
start /w dism /online /enable-feature /featurename:IIS-BasicAuthentication
start /w dism /online /enable-feature /featurename:IIS-WindowsAuthentication
start /w dism /online /enable-feature /featurename:IIS-ISAPIExtensions
start /w dism /online /enable-feature /featurename:IIS-ASP
start /w dism /online /enable-feature /featurename:IIS-ISAPIFilter
rem WIN 8 Only
start /w dism /online /enable-feature /featurename:NetFx3
start /w dism /online /enable-feature /featurename:NetFx4Extended-ASPNET45
start /w dism /online /enable-feature /featurename:IIS-NetFxExtensibility
start /w dism /online /enable-feature /featurename:IIS-ASPNET
start /w dism /online /enable-feature /featurename:IIS-ServerSideIncludes
rem WIN 8 Only
start /w dism /online /enable-feature /featurename:IIS-NetFxExtensibility45
start /w dism /online /enable-feature /featurename:IIS-ASPNET45
echo IIS installation complete它将从internet下载IIS并安装在本地计算机上。我使用C#代码来调用这个installiis.bat。代码是
batchCommand = installiis.bat;
procStartInfo = new ProcessStartInfo();
procStartInfo.WorkingDirectory = targetDir;
procStartInfo.FileName = batchCommand;
procStartInfo.Arguments = argument;//this is argument
procStartInfo.CreateNoWindow = true;
procStartInfo.UseShellExecute = true;
procStartInfo.Verb = "runas";
proc.StartInfo = procStartInfo;
proc.Start();
proc.WaitForExit();此代码在win7和其他平台上运行良好,但在Windows 2008 Server和windows 8中无法使用C#代码启动批处理文件。命令窗口在启动后立即消失。但是,当我手动单击并以管理员身份运行时,相同的批处理文件工作正常。任何人请给出任何解决方案。
发布于 2013-04-29 21:56:59
我认为您必须向您的程序添加一个应用程序清单,以请求提升您的应用程序的权限。
http://msdn.microsoft.com/en-us/library/windows/desktop/bb756929.aspx
https://stackoverflow.com/questions/16280434
复制相似问题