以管理员身份在批处理文件中运行powershell脚本

时间:2014-01-03 09:48:53

标签: batch-file powershell powershell-v2.0

我有一个powershell脚本。为了运行这个sript,我写了一个批处理文件 这是批处理文件的代码:

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

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

当我双击批处理文件时,我希望我的脚本Hotfix-Automation-Installer.ps1以管理员身份运行。
我如何以管理员身份运行此脚本?

1 个答案:

答案 0 :(得分:1)

阅读Matt关于此链接的文章:
How can I auto-elevate my batch file, so that it requests from UAC administrator rights if required?

他已提供完整的脚本以从当前会话升级到管理员会话。安静有帮助。