Run a powershell script in batch file as administrator

丶灬走出姿态 提交于 2020-01-03 17:22:27

问题


I have a powershell script. To run this sript, I have written a batch file.
Here is code of batch file:

:: psscript.bat
set psscript='%CD%\Hotfix-Automation-Installer.ps1'

echo Running PowerShell Script: %psscript%
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe ^&%psscript% %*

When I double-click on batch file, I want my script Hotfix-Automation-Installer.ps1 to be run as an administrator.
How I can run this script as administrator?


回答1:


Read Matt's article on this link:
How can I auto-elevate my batch file, so that it requests from UAC administrator rights if required?

He has given complete script to elevate from current session to administrator session. Quiet helpful.



来源:https://stackoverflow.com/questions/20900755/run-a-powershell-script-in-batch-file-as-administrator

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