Hello together,
I'm working on a program to start executables.
In my example 3 VBScripts. The scripts just count to 20.
If I call the scripts like this:
int code1 = wxExecute("CScript.exe D:/my_projects/cpp/Exec/App1.vbs", wxEXEC_SYNC);
int code2 = wxExecute("CScript.exe D:/my_projects/cpp/Exec/App2.vbs", wxEXEC_SYNC);
int code3 = wxExecute("CScript.exe D:/my_projects/cpp/Exec/App3.vbs", wxEXEC_SYNC);
The scripts are starting but they are passing each other.
Has anyone an idea?
Thank you very much.
kea_
Can't get wxExecute wxEXEC_SYNC to work. Topic is solved
Can't get wxExecute wxEXEC_SYNC to work.
- Attachments
-
- Output.jpg (29.87 KiB) Viewed 2130 times
-
- Super wx Problem Solver
- Posts: 264
- Joined: Mon Aug 07, 2006 3:25 pm
- Location: Baia Mare, Romania
- Contact:
Hi.
Did you check if CScript.exe waits until the VBS is executed before returning or it returns immediately, before the VBS completes. Or do the VBS "load into the background" and keep running.
If any of the above is true, the output you have is quite normal since wxWidgets will wait only CScript.exe to return.
Regards
Did you check if CScript.exe waits until the VBS is executed before returning or it returns immediately, before the VBS completes. Or do the VBS "load into the background" and keep running.
If any of the above is true, the output you have is quite normal since wxWidgets will wait only CScript.exe to return.
Regards
Software is like sex,
It's better when it's free.
~Linus Torvalds
It's better when it's free.
~Linus Torvalds
Hello framepointer,
for me it looks like a b... or it does not work.
See the screenshot.
I have the scripts in this way started an checked it width the procexp:
int code1 = wxExecute("CScript.exe D:/my_projects/cpp/Exec/App1.vbs", wxEXEC_SYNC);
int code2 = wxExecute("CScript.exe D:/my_projects/cpp/Exec/App2.vbs", wxEXEC_SYNC);
int code3 = wxExecute("CScript.exe D:/my_projects/cpp/Exec/App3.vbs", wxEXEC_SYNC);
Do you have an idea?
Thank you for your answer.
kea_
for me it looks like a b... or it does not work.
See the screenshot.
I have the scripts in this way started an checked it width the procexp:
int code1 = wxExecute("CScript.exe D:/my_projects/cpp/Exec/App1.vbs", wxEXEC_SYNC);
int code2 = wxExecute("CScript.exe D:/my_projects/cpp/Exec/App2.vbs", wxEXEC_SYNC);
int code3 = wxExecute("CScript.exe D:/my_projects/cpp/Exec/App3.vbs", wxEXEC_SYNC);
Do you have an idea?
Thank you for your answer.
kea_
- Attachments
-
- script.jpg (36.45 KiB) Viewed 2111 times
Hello framepointer,
for me it looks like a b... or it does not work.
See the screenshot.
I have the scripts in this way started an checked it width the procexp:
int code1 = wxExecute("CScript.exe D:/my_projects/cpp/Exec/App1.vbs", wxEXEC_SYNC);
int code2 = wxExecute("CScript.exe D:/my_projects/cpp/Exec/App2.vbs", wxEXEC_SYNC);
int code3 = wxExecute("CScript.exe D:/my_projects/cpp/Exec/App3.vbs", wxEXEC_SYNC);
Do you have an idea?
Thank you for your answer.
kea_
for me it looks like a b... or it does not work.
See the screenshot.
I have the scripts in this way started an checked it width the procexp:
int code1 = wxExecute("CScript.exe D:/my_projects/cpp/Exec/App1.vbs", wxEXEC_SYNC);
int code2 = wxExecute("CScript.exe D:/my_projects/cpp/Exec/App2.vbs", wxEXEC_SYNC);
int code3 = wxExecute("CScript.exe D:/my_projects/cpp/Exec/App3.vbs", wxEXEC_SYNC);
Do you have an idea?
Thank you for your answer.
kea_
- Attachments
-
- script.jpg (36.45 KiB) Viewed 2110 times
-
- Super wx Problem Solver
- Posts: 264
- Joined: Mon Aug 07, 2006 3:25 pm
- Location: Baia Mare, Romania
- Contact:
Hi.
Try to start a simple console application using wxExecute.
For example write a simple console app, that will print out it's first argument to stdout and exit wight after. Use that exe as a control.
Run your sample and see the output. This way you can test if there is anything wrong with the wxExecute().
But as said, I suspect that cscript.exe loads into the memory and returns control to your application before the vbs scripts are finished running. This way the 3 scripts run at the same time, hence the messed up output.
Regards
Try to start a simple console application using wxExecute.
For example write a simple console app, that will print out it's first argument to stdout and exit wight after. Use that exe as a control.
Run your sample and see the output. This way you can test if there is anything wrong with the wxExecute().
But as said, I suspect that cscript.exe loads into the memory and returns control to your application before the vbs scripts are finished running. This way the 3 scripts run at the same time, hence the messed up output.
Regards
Software is like sex,
It's better when it's free.
~Linus Torvalds
It's better when it's free.
~Linus Torvalds
Hello framepointer,
I've got my solution.
See the code below it does exactly what I like:
I think it was not a problem of vbs because I coded a script width "WSHShell.Run "App1.vbs", 3, true" and width this it worked perfect.
Thank you for your help and
greetings from the snowing Liechtenstein
kea_
I've got my solution.
See the code below it does exactly what I like:
Code: Select all
void csExec::DoExecute(Execute exec){
if(exec.bSync){
wxProcess *process = new wxProcess(wxPROCESS_REDIRECT);
long pid = wxExecute(exec.sExecute, wxEXEC_ASYNC, process);
process->Redirect();
if(process){
wxInputStream *is = process->GetInputStream();
wxTextInputStream tStream(*is);
while(!is->Eof()){
cout << tStream.ReadLine() << endl;
}
}
}else{
wxExecute(exec.sExecute, wxEXEC_ASYNC);
cout << "ASync" << endl;
}
}
Thank you for your help and
greetings from the snowing Liechtenstein
kea_