VBScript- 作为管理员单行 [英] VBScript- Single line as administrator

查看:30
本文介绍了VBScript- 作为管理员单行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用shell.run命令以管理员身份运行指定程序?

Is it possible to use the shell.run command to run the specified program as an administrator?

例如:

shell.run(cmd.exe) <---Run this as admin
shell.run(Notepad) <---Run this as normal

我知道我可以执行脚本以管理员身份运行,但这意味着脚本中的所有内容都以管理员身份执行.

I know i can execute the script to run as admin but that means everything inside that script is executed as an administrator.

我的另一个选择是将脚本分开并以管理员身份运行,并将需要以管理员身份运行的内容包含在该脚本中,然后调用另一个脚本来正常运行并运行该脚本.

My other option was to seperate the scripts and run one as admin and include what needs to be ran as admin in that script, then call another script to run and run that one as normal.

推荐答案

Set oShell = CreateObject("Shell.Application")
oShell.ShellExecute "cmd.exe", , , "runas", 1
oShell.Run "nodepad.exe"

(来源:http:///social.technet.microsoft.com/Forums/eu/ITCG/thread/310e57f9-2367-4293-9f97-53d0e077aacc)

(更多信息:http://ss64.com/vb/shellexecute.html)

这篇关于VBScript- 作为管理员单行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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