Trevor Sullivan's Tech Room

Minding the gap between administration and development

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

Listening for a signal

Listening for a signal

2. Send the signal (from a different command prompt)

Send the signal

3. Observe the listener result

See listener results

 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.


2 Responses to “Windows 7 – WaitFor.exe”

  1. Pecos Bill said

    As per the info on TechNet, the waitfor command sends the signal to the ENTIRE domain if you don’t use the /s switch to target a machine. Needless network traffic for large domains. It also does say that if you use /s without a system, it defaults to the localhost but I’ve no idea how to default it without error. So, probably best to name the system to target.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: