[Closed] Waiting for exe to process
Hiya,
Is there a way to call an external Exe file and wait for it to finish?
Right now I use ShellLaunch but that will instantly skip to the next line of code and I need to wait for some files to be created.
Any ideas?
/Andreas
DOSCommand ?
That will wait for the application to exit and returns the exit code ( error level ) of the app.
I’ve been using dotnet for this kind of stuff, as it gives the ability to check whether the process is over or not, but if DOSCommand can wait, then maybe its the right solution
....
....
local comandLine = ( "a -afzip -m5 -ep -dh " + "\"" + zipFileFull + "\"" + filesStr )
local winrarPath = "C:\\Program Files\\WinRAR\\WinRAR.exe"
local n_startInfo = dotnetobject "System.Diagnostics.ProcessStartInfo" winrarPath
n_startInfo.Arguments = comandLine
n_startInfo.CreateNoWindow = true
local n_process = dotnetclass "System.Diagnostics.Process"
local winrarProcess = undefined
try (
winrarProcess = n_process.Start n_startInfo
)
catch (
print "error launching winrar "
return false
)
-- sleep while winrar is zipping
do ( sleep 1 )
while ( not winrarProcess.HasExited )
-- error code returned
if not ( winrarProcess.ExitCode == 0 ) then (
print "zipping was not successful"
return false
)
-- close process
winrarProcess.Close()
....
....
if these files are bitmapFiles you could simply use a 32bpp dummyFile wich you copy to the new Location with name and extention and then overwrite with the new bitmap. this way you don’t have to wait and can let the >process< work in the background