我的目標:我想使用VBS爲當前用戶創建一個桌面快捷方式,使用帶有參數和變量(InputBox)提示符的RunAs命令運行它用戶輸入的變量。VBS創建帶有RunAs參數的桌面快捷方式
OS:X64 Win7的
工作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「」「''。 – Lankymart