Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

I have this "test.bat" to call "myprogram.exe"

Note: test.bat is fixed by Noodles

"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"

I used this "test.vbs" to call "test.bat"

On Error Resume next
mensaje = MSGBOX ("Start Test PC", vbOKCancel, "Test PC")
If mensaje = vbOK Then
SCRIPT = "test.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 Test",3,"Test PC",16)
End If

As you can see, they are too many scripts to call a simple program.

What i want is suppress "test.bat" and include its code into "test.vbs", for use only one script to call myprogram.exe

share|improve this question
    
You can put multiple commands on one line. So Execute cmd /c start "" c:\windows\notepad & Dir & Set Fred=Cat & Set F & Pause. Because you aren't typing you must use start to start programs if you don't want to wait for the program to exit. Call is used for starting batch files. Normally to start a program you only specify the exe. See my answer here on the three ways to start programs stackoverflow.com/questions/31820569/… – Noodles 1 hour ago
    
There is no point in On Error GoTo 0 as the last line. The error context is destroyed immediately after that line, so it does nothing but make code slower. Your last three lines in the batch file also do nothing. They run and then the environment they change gets destroyed, so it does nothing but make code slower. – Noodles 1 hour ago
    
Hi noodles. Thanks. You mean replace the contents of test.bat by: call "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 (???). In this case how to put into vbs? – BrianC 50 mins ago
    
Don't use call to start a program. Use the program's name (to wait for program to exit) or start (start the program and don't wait) depending on the behaviour desired. "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" A set of opening and closing quotes for VBS. Quotes within the string are escaped so "" means a single " within the string. – Noodles 42 mins ago
    
Also you can't Change then read vars without turning on a special mode. See cmd /c set fred=cat & Echo %Fred% and with special mode (see cmd /? and setlocal /?) cmd /v:on /c set fred=cat & echo !fred!. – Noodles 33 mins ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.