【Powershell】以指定的账户运行程序
2014-09-17 11:49
387 查看
很多的情况下,需要以指定的账户运行程序;
例如在非管理员账户下要以管理员权限运行程序,就可以用下面的PS脚本:
参考网址:
http://biancheng.dnbcw.info/mssql/374833.html
http://www.pstips.net/powershell-launching-applications-with-alternate-credentials.html
例如在非管理员账户下要以管理员权限运行程序,就可以用下面的PS脚本:
<# Script Editor: Snail Yu Date: 2014-09-17 #> $uname=".\administrator" #指定用户名,“.\administrator”代表本地管理员 $pwd=ConvertTo-SecureString "password" -AsPlainText –Force #“password”指本地管理员的密码 $cred=New-Object System.Management.Automation.PSCredential($uname,$pwd) #将用户和密码保存在这个变量中 Start-Process -FilePath "C:\Program Files (x86)\Tencent\QQ\Bin\QQ.exe" -Credential $cred #以指定的账户运行QQ
参考网址:
http://biancheng.dnbcw.info/mssql/374833.html
http://www.pstips.net/powershell-launching-applications-with-alternate-credentials.html
相关文章推荐
- 如何注册程序在指定时间运行
- 用dos批处理程序检测是否安装.netframework,并自动安装后运行指定程序(.net自启动光盘的制做)
- 转载:如何指定程序在Vista上面需要提升权限运行(Elevated)
- 转载:如何指定程序在Vista上面需要提升权限运行(Elevated)
- 转载:如何指定程序在Vista上面需要提升权限运行(Elevated)
- 检测到指定的WEB服务器运行的不是ASP.NET 1.1版,您无法运行ASP.NET应用程序或服务和创建ASP.NET程序时候发生错误 HTTP/1.0 500 Server Error的解决方法
- 修改注册表让系统“运行指定程序;禁用指定程序”
- 转载:如何指定程序在Vista上面需要提升权限运行(Elevated)
- 转载:如何指定程序在Vista上面需要提升权限运行(Elevated)
- 转载:如何指定程序在Vista上面需要提升权限运行(Elevated)
- 转载:如何指定程序在Vista上面需要提升权限运行(Elevated)
- 转载:如何指定程序在Vista上面需要提升权限运行(Elevated)
- 转载:如何指定程序在Vista上面需要提升权限运行(Elevated)
- 如何在u盘插上以后就自动运行指定的程序?
- 转载:如何指定程序在Vista上面需要提升权限运行(Elevated)
- 改注册表,在一定时间内只能运行指定程序,知道用组策略管理器,可以实现,不过我想用编程的方法。
- 转载:如何指定程序在Vista上面需要提升权限运行(Elevated)
- 转载:如何指定程序在Vista上面需要提升权限运行(Elevated)
- 转载:如何指定程序在Vista上面需要提升权限运行(Elevated)
- 转载:如何指定程序在Vista上面需要提升权限运行(Elevated)