我有“launchprogram.bat”来调用“myprogram.exe”(实名ppbS.exe)
原始代码launchprogram.bat
call "ppbS.exe"
set ppbPath=ppbS
set pathHold=%path%
set path=%ppbPath%;%path%
ppbS create "ppbS" ShowPct 1 No Crawl 1 SetCrawlTime 1 300000
ppbS settext 1 "Start myprogram... Be pacient"
second.bat
ppbS shutdown
set path=%pathHold%
set pathHold=
set ppbPath=
注意:“second.bat”是另一个bat run hide
额外:此版本的“launchprogram.bat”由Noodles提供
"Cmd /c ""ppbS.exe"" & Dir & set ppbPath=ppbS & set pathHold=%path% & set path=%ppbPath%;%path% & ppbS create ""ppbS"" ShowPct 1 No Crawl 1 SetCrawlTime 1 300000 & ppbS settext 1 ""Start myprogram... Be pacient"" & second.bat & ppbS shutdown"
反正;我使用这个“start.vbs”来调用“launchprogram.bat”
On Error Resume Next
mensaje = MsgBox("Start myprogram", vbOKCancel, "myprogram")
If mensaje = vbOK Then
Script = "launchprogram.bat"
Set objshell = CreateObject("Wscript.Shell")
strPath = Wscript.ScriptFullName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPath)
strFolder = objFSO.GetParentFolderName(objFile)
NewPath = objFSO.BuildPath(strFolder, Script)
Set objshell = CreateObject("wscript.shell")
objshell.Run NewPath, vbHide
Else
Set objshell = CreateObject("Wscript.shell")
rmensaje = objshell.popup("Cancel myprogram", 3, "myprogram", 16)
End If
正如您所看到的,它们是太多的脚本和太多的代码来调用简单的程序。
请求:
我想删除“launchprogram.bat”并将其代码放入“start.vbs”,只使用一个脚本调用“myprogram.exe”
非常感谢
答案 0 :(得分:1)
objshell.run "Cmd /c ""myprogram.exe"" & Dir & set ppbPath=myprogram & set pathHold=%path% & set path=%ppbPath%;%path% & ppbS create ""myprogram"" ShowPct 1 No Crawl 1 SetCrawlTime 1 300000 & ppbS settext 1 ""Start myprogram... Be pacient"" & ppbS shutdown", vbhide
未定义VBHide。如果是,它将为0.由于未定义,它被视为0.这是因为常量在VBScript中不可用。这很幸运,VBHide恰好是0。