首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何通过C#在Windows2008Windows中安装IIS

如何通过C#在Windows2008Windows中安装IIS
EN

Stack Overflow用户
提问于 2013-04-29 21:52:56
回答 1查看 1.3K关注 0票数 2

我得到了一个批处理文件,其中包含:

代码语言:javascript
复制
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。代码是

代码语言:javascript
复制
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 Serverwindows 8中无法使用C#代码启动批处理文件。命令窗口在启动后立即消失。但是,当我手动单击并以管理员身份运行时,相同的批处理文件工作正常。任何人请给出任何解决方案。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-29 21:56:59

我认为您必须向您的程序添加一个应用程序清单,以请求提升您的应用程序的权限。

http://msdn.microsoft.com/en-us/library/windows/desktop/bb756929.aspx

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16280434

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档