Hello all.
I'm trying to code and create an automated process to execute batch script files using Purebasic.
An example on what I'm trying to do via command line...
xpto.bat --mode ccXXxx project new --name files2place --device XXXXXXX --mode production --overwrite > xpto.log
In the end I want to get also the respose to the command placed and checkout some information...
Any idea on how can I solve this?
Best Regards
Nuno
Doubts executing batch script files on windows
Re: Doubts executing batch script files on windows
Since you are redirecting all output to a file, you will not see anything until the program is finished.
So you have to wait (#PB_Program_Wait) and then display the log file, either by reading it as a text file or by displaying it with the associated program.
Something like this:
Without the redirection, it is possible to see the result line by line as in the example given in the help on RunProgram()
PS. If one of your parameter need double quote, uses C convention formatting, like this:
So you have to wait (#PB_Program_Wait) and then display the log file, either by reading it as a text file or by displaying it with the associated program.
Something like this:
Code: Select all
Run = RunProgram("cmd",
"/c xpto.bat --mode ccXXxx project new --name files2place --device XXXXXXX --mode production --overwrite > xpto.log",
#PB_Program_Hide, #PB_Program_Wait)
If Run
RunProgram("xpto.log")
; RunProgram("notepad", "xpto.log", "")
EndIf
PS. If one of your parameter need double quote, uses C convention formatting, like this:
Code: Select all
For:
"C:\Program Files"
Uses:
~" \"C:\\Program Files\" ... "