Suspend Code While Waiting for Shelled Process

This “wait” routine suspends your code and waits for the shelled process to finish. It comes in handy when you need to run another scriptatch file during your process. Use this calling syntax:

 Private sub cmdPrint_Click()	WaitForProcessToEnd "C:PLOTTER.BAT"	'Let the user know when the process is finished.	MsgBox "The process is finished! "End Sub

Here are the API declarations:

 Public Const INFINITE = -1&Public Declare Function WaitForSingleObject _	Lib "kernel32" (ByVal hHandle As Long, _	ByVal dwMilliseconds As Long) As LongPublic Declare Function OpenProcess Lib _	"kernel32" (ByVal dwAccess As Long, _	ByVal fInherit As Integer, _	ByVal hObject As Long) As LongPublic Sub WaitForProcessToEnd(cmdLine As String)	'You can substitute a discrete time 	'value in milliseconds for INFINITE.	Dim retVal As Long, pID As Long, pHandle _		As Long	pID = Shell(cmdLine)	pHandle = OpenProcess(&H100000, True, pID)	retVal = WaitForSingleObject(pHandle, INFINITE)End Sub
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS