Windows 7 – WaitFor.exe
Posted by Trevor Sullivan on 2009/11/19
So I just randomly came across this utility built into Windows 7 that simply sends or waits for a signal (message). This could be useful for batch scripts that need to wait for something to happen on a local (or remote) machine.
Here is the help output from the command:
C:\Users\Administrator>waitfor /? WaitFor has two ways of working:Syntax 1: to send a signal WAITFOR [/S system [/U user [/P [password]]]] /SI signal Syntax 2: to wait for a signal WAITFOR [/T timeout] signal Description: This tool sends, or waits for, a signal on a system. When /S is not specified, the signal will be broadcasted to all the systems in a domain. If /S is specified, then the signal will be sent only to the specified system. Parameter List: /S system Specifies remote system to send signal to. /U [domain\]user Specifies the user context under which the command should execute./P [password] Specifies the password for the given user context. /SI Sends the signal across the net to waiting machines /T timeout Number of seconds to wait for signal. Valid range is 1 - 99999. Default is to wait forever for signal. signal The name of the signal to wait for or to send. /? Displays this help message. NOTE: A system can wait for multiple unique signal names. The signal name cannot exceed 225 characters and cannot contain characters other than a-z, A-Z, 0-9 and ASCII characters in the range 128-255. Examples: WAITFOR /? WAITFOR SetupReady WAITFOR CopyDone /T 100 WAITFOR /SI SetupReady WAITFOR /S system /U user /P password /SI CopyDone
Let’s look at an example of how to use it. All we have to do is set up a listener, and then use another command prompt to send the signal to it. For the sake of example, we’ll use the message “blah“.
1. Set up the listener
2. Send the signal (from a different command prompt)
3. Observe the listener result
And that’s all there is to it! A simple, but handy utility if you’re writing batch scripts! It even sends a signal to a remote system, using the /S switch! You could also use this utility with the Microsoft Deployment Toolkit (MDT) 2010, to help control the flow of your task sequence.