Creating batch jobs in PowerShell

Question:

Imagine a DOS style .cmd file which is used to launch interdependent windowed applications in the right order.

Example:
1) Launch a server application by calling an exe with parameters.
2) Wait for the server to become initialized (or a fixed amount of time).
3) Launch client application by calling an exe with parameters.

What is the simplest way of accomplishing this kind of batch job in PowerShell?

Answer:

Remember that PowerShell can access .Net objects. The Start-Sleep as suggested by Blair Conrad can be replaced by a call to WaitForInputIdle of the server process so you know when the server is ready before starting the client.


You could also use Process.Start to start the process and have it return the exact Process. Then you don’t need the get-process.

Source:

Creating batch jobs in PowerShell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply