Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vb.net check if process I started is done

Tags:

vb.net

I have started a process:

Dim getUdpate as Process
getUpdate = New Process
getUpdate.StartInfo.FileName = "C:\UTIL\GETBTCH.BAT"
getUpdate.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
getUpdate.StartInfo.UseShellExecute = False
getUpdate.StartInfo.WorkingDirectory = "C:\UTIL\"
getUpdate.Start()
getUpdate.Close()

Then, I want to Run another process but I want to check first if the getUpdate process is already finished.

How do I check if the process is already finished?

I already tried to look at the processes ID, but it only display cmd.exe and there are a lot of cmd.exe as the processes ID so I can't just go and stop all of those.

like image 727
PaulPolon Avatar asked Jan 12 '23 16:01

PaulPolon


2 Answers

You can check the HasExited property of the process. It will return true if the process has ended, and false if it is still running.

You will need to check this before you call Close() on your getUpdate Process object. So getProcess will have to remain open until the procsses has exited.

like image 134
shf301 Avatar answered Apr 19 '23 23:04

shf301


Try:

getUpdate.WaitForExit(); instead of

getUpdate.Close()

like image 29
David Tansey Avatar answered Apr 20 '23 00:04

David Tansey