Currently, I am using shellexecute to execute a batch file. The batch file gets passed parameters, and executes mysql.exe, which allows me to execute script files on a database.
For example:
result = ShellExecute(hwnd, "open", "theBatch.bat", parameter1 & " " & parameter2 & " " & parameter3 & " " & parameter4 & " " & parameter5 & " " & thePathToBatch, App.Path, 0)
Each parameter 1 through 5 is a required parameter for the mysql.exe (username, password, host, theDatabase, & the filename to execute,thepath to theBatch.bat, thepath to mysql.exe etc). Without these parameters, the mysql.exe wont execute correctly as it cant access the server.
BatchFile call to mysql ex:
%ThePathToMySql.Exe%mysql -h %parameter1% -u %parameter2% -p%parameter3% -B %parameter4% < %parameter5%
Problem:
The call to the ShellExecute command is in a for loop, because there is more then one file to execute. However, the second call to the ShellExecute happens before the first one gets to successfully completed.
Currently, i use sleep x after the first call to give it time to execute before continuing in the for loop, and this appears to work.
Question:
Is there something better then using sleep to be certain that the script has executed correctly, just incase the interval isnt enough time to execute the script?
I've tried placing '/wait' in the batch file before/after the call to the mysql.exe is made, but this doesn't seem to work. I've also looked at the ExecuteAndWait function, but Im wondering if this will allow me to pass the parameters 1 through 5 as listed above?
Any thoughts?
For example:
result = ShellExecute(hwnd, "open", "theBatch.bat", parameter1 & " " & parameter2 & " " & parameter3 & " " & parameter4 & " " & parameter5 & " " & thePathToBatch, App.Path, 0)
Each parameter 1 through 5 is a required parameter for the mysql.exe (username, password, host, theDatabase, & the filename to execute,thepath to theBatch.bat, thepath to mysql.exe etc). Without these parameters, the mysql.exe wont execute correctly as it cant access the server.
BatchFile call to mysql ex:
%ThePathToMySql.Exe%mysql -h %parameter1% -u %parameter2% -p%parameter3% -B %parameter4% < %parameter5%
Problem:
The call to the ShellExecute command is in a for loop, because there is more then one file to execute. However, the second call to the ShellExecute happens before the first one gets to successfully completed.
Currently, i use sleep x after the first call to give it time to execute before continuing in the for loop, and this appears to work.
Question:
Is there something better then using sleep to be certain that the script has executed correctly, just incase the interval isnt enough time to execute the script?
I've tried placing '/wait' in the batch file before/after the call to the mysql.exe is made, but this doesn't seem to work. I've also looked at the ExecuteAndWait function, but Im wondering if this will allow me to pass the parameters 1 through 5 as listed above?
Any thoughts?