Page 1 of 1
Running a bat file
Posted: Fri Jun 22, 2007 2:04 pm
by Trond
No matter what I do it opens its own console window!
Code: Select all
OpenConsole()
Delay(500)
; RunProgram("c:\test.bat") (works)
ShellExecute_(0, "open", "c:\test.bat", "", "", #SW_NORMAL)
Delay(500)
The bat file:
Posted: Fri Jun 22, 2007 2:20 pm
by Max
Have you tried to compile with /console option?.
Posted: Fri Jun 22, 2007 2:39 pm
by Trond
Yes.
Posted: Fri Jun 22, 2007 3:47 pm
by Kale
http://www.purearea.net/pb/english/manu ... ogram.html
Code: Select all
RunProgram(FileName$, Parameter$, WorkingDirectory$, #PB_Program_Hide )

Posted: Fri Jun 22, 2007 4:05 pm
by thefool
He would like it to redirect the input. And he don't want to use runprogram [which does redirect the input if you are compiling using /console option]
Posted: Fri Jun 22, 2007 4:18 pm
by Trond
The RunProgram() in the code in the first post works, but I want to figure out how to do it using API. I'd like the output from the bat file inside my console window, not hidden.
Posted: Fri Jun 22, 2007 4:20 pm
by netmaestro
Around a year ago there was a similar thread, but damned if I can find it now. You want the output of the batch sent to your console window instead of opening its own new one, right? That's what the thread dealt with and it was solved, so it's a matter of finding it.
Posted: Fri Jun 22, 2007 4:34 pm
by Trond
netmaestro wrote:You want the output of the batch sent to your console window instead of opening its own new one, right?
Yes.
Edit: I found something like that, but it uses RunProgram().
Edit: WinExec_("c:\test.bat", 0) works, but is deprecated.
Posted: Fri Jun 22, 2007 7:05 pm
by Trond
Works:
Code: Select all
OpenConsole()
GetStartupInfo_(@si.STARTUPINFO)
pi.PROCESS_INFORMATION
CreateProcess_("c:\test.bat", "", 0, 0, 1, 0, 0, 0, @si, @pi)
WaitForSingleObject_(pi\hProcess, 10000)
I still don't understand why ShellExecute_() doesn't work though.