Use vb.net to continue after the external program is running.
Source: Internet
Author: User
I have introduced how to run external programs last time. Today I will continue to talk about this topic:
1. When there are many times, we need to call the external EXE program and wait for it to finish running before we can continue the following actions. Then how can we implement it? Please refer to the following code.
'How to wait for the external program to run.
'Read files from the system folder
Dim sysFolder As String = _
Environment. GetFolderPath (Environment. SpecialFolder. System)
'Create a new process structure
Dim pInfo As New ProcessStartInfo ()
'Sets the employee filenameas the eula.txt of the system data.
PInfo. FileName = sysFolder & "eula.txt"
'Run the file
Dim p As Process = Process. Start (pInfo)
'Wait until the program is loaded
P. WaitForInputIdle ()
'Wait for the trip to exit
P. WaitForExit ()
'Continue to execute the following code
MessageBox. Show ("continue executing code ")
2. We want to forcibly close it in five seconds, instead of manually disabling it.
'Set the exit time
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service