在批处理文件中以管理员身份运行PowerShell脚本 [英] Run a powershell script in batch file as administrator

查看:4449
本文介绍了在批处理文件中以管理员身份运行PowerShell脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PowerShell脚本。要运行这个sript,我写一个批处理文件。结果
下面是批处理文件code:

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% %*

在我的批处理文件,双击,我希望我的脚本修补程序的自动化,Installer.ps1要以管理员身份运行。结果
我怎么能以管理员身份运行此脚本?

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?

推荐答案

阅读马特的文章此链接:结果
<一href=\"http://stackoverflow.com/questions/7044985/how-can-i-auto-elevate-my-batch-file-so-that-it-requests-from-uac-admin-rights\">How我可以自动提升我的批处理文件,这样它的UAC管理员权限,如果需要的话要求?

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

他给了完整的脚本,从当前会话提升到管理员会话。安静的帮助。

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

这篇关于在批处理文件中以管理员身份运行PowerShell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆