下一頁評論代碼段應做的工作(大多數語句和命令逐項可理解的緣故):
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