【发布时间】:2017-02-17 20:56:19
【问题描述】:
我的目标:我正在尝试使用 VBS 在运行它的当前用户下为 IE 创建一个桌面快捷方式,并使用带有参数的 RunAs 命令和一个变量(InputBox)提示符,该提示符用用户的输入填充变量。
操作系统:Win7 x64
Working BAT:(手动填写域名\用户名)
%windir%\system32\runas.exe /u:Domain\Username "%ProgramFiles%\Internet Explorer\iexplore.exe"
非工作 VBS:
set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
strUser = InputBox ("Please Enter your Domain Account")
set oUrlLink = WshShell.CreateShortcut(strDesktop & "\RunAs Internet Explorer (Domain Account).lnk")
oUrlLink.TargetPath = ("%windir%\system32\runas.exe" /u:DOMAIN\"" & strUser & "%ProgramFiles%\Internet Explorer\iexplore.exe")
oUrlLink.IconLocation = "%ProgramFiles%\Internet Explorer\iexplore.exe"
oUrlLink.Save
【问题讨论】:
-
你需要正确转义
TargetPath中的字符串,当在字符串中使用引号时,双引号是oUrlLink.TargetPath = "%windir%\system32\runas.exe /u:DOMAIN\" & strUser & " ""%ProgramFiles%\Internet Explorer\iexplore.exe"""这样的规则。
标签: vbscript windows-7-x64 runas