Windows has a waitFor.exe command available for use in in batch and powershell (and any other language that can call an executable), which allows you to sends or waits for a signal on a system, thereby allow execution synchronization across a network - although it also works fine on a single computer.

It's very useable, but due to lack of good documentation it's mostly abused to insert a pause in batch files using it's timeout option.

The only documentation I can find is this: https://technet.microsoft.com/en-us/library/cc731613(v=ws.11).aspx, which provides a very basic usage usage for the specific waitFor.exe command in Windows - but offers nothing about how it's actually implemented nor how I ensure that it will work (== isn't blocked by some firewall) in a given network.

I'd like to be able to embed sending and receiving these signals in my own code, but can't find anything on how to do so - not even the most basic protocol and packet format seems available.

My questions,

  1. What network protocol is used for this? (As @Seth mentioned, it's probably RPC - but then, how is it implemented?)
  2. What is the packet format used?
  3. What network ports are required to route these signals?

In other words, I need to know everything needed to implement this in my own programs.

Thanks for your time!

  • As by the examples the signal seems to be a simple string you can probably send any string. Usually Windows relies on RPC calls for such functions. – Seth Aug 18 '17 at 9:58
  • Just found @eryksun 2014 SO comment: waitfor.exe is based on mailslots. waitfor someevent creates a mailslot named \\.\mailslot\WAITFOR.EXE\someevent. Sending the signal via waitfor /si someevent opens a handle for \\*\mailslot\WAITFOR.EXE\someevent, where "*" has the UNC provider broadcast the message to every computer on the domain. waitfor /s %COMPUTERNAME% /si someevent specifically opens \\[computer_name]\mailslot\WAITFOR.EXE\someevent instead of broadcasting the signal. – fsteff Nov 25 '17 at 21:01

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.