Windows 8 Powershell Enable-WindowsOptionalFeature bat file

三世轮回 提交于 2019-12-13 02:13:20

问题


I have a .bat file that runs a powershell script. This is it

powershell -Command "& {Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole}"

I have done this before and if I wanted to add another command I would put a semicolon before the closing brace and continue the script.

This command however after completed requires that I choose wheter or not to restart the computer with a Y or N.

Does anyone know how to pass this in an argument or avoid this step all together?

Thanks in advance

Note: you have to run the .bat file as adminstrator


回答1:


From Get-Help Enable-WindowsOptionalFeature -Full:

 -NoRestart [<SwitchParameter>]
     Suppresses reboot. If a reboot is not required, this command does nothing. This option will keep the
     application from prompting for a restart or keep it from restarting automatically.

Add the -NoRestart flag to Enable-WindowsOptionFeature to suppress the reboot. If you do want to reboot after completion, use the command Restart-Computer.



来源:https://stackoverflow.com/questions/16859979/windows-8-powershell-enable-windowsoptionalfeature-bat-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!