下一页评论代码段应做的工作(大多数语句和命令逐项可理解的缘故):
option explicit
On Error GoTo 0
' declare variables
Dim WshShell, sUserProfile, strCommand, fso
' assign all object references to appropriate variables
Set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
' get an environment variable's expanded value
sUserProfile = WshShell.ExpandEnvironmentStrings("%UserProfile%")
' build command to run
strCommand = """" _
& fso.BuildPath(fso.BuildPath(sUserProfile, "Desktop"), "Thingy.bat") & """"
Wscript.Echo "(debug) command to run" & vbNewLine & strCommand
WshShell.Run strCommand
如果它总是出现在桌面上,您可以使用'%USERPROFILE%'或与vbs中相同的代码... – geisterfurz007
将脚本路径获取到变量中。 'scriptPath = FSO.GetParentFolderName(wscript.ScriptFullName)' – Squashman