A script/windows command to Gracefully Wait/Shut down

  command, pos, powershell, script, windows

I am trying to implement a script / command that would gracefully shut down an application and relaunch moments later (lets say 30 seconds). So far, I’ve got the script to do a graceful shut down and have not worked on the relaunch of the application yet.

The issue I am having is, this application is on about 100 terminals (different stores with POS stations – this is meant to gracefully shutdown their POS terminal app). However, I am struggling to figure out how to make this program wait for the user in the terminal to log off if their in the middle of a transaction. Right now, there is a delay and the execution ends if the user is logged in and does not wait for the user to log off.

Is there a way to make the executed script wait until a user is logged off to gracefully shut down the application rather than quit? Here is a sample of the xml I have:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
    <URI> Gracefull Shutdown</URI>
    <Principal id="Author">
  <Actions Context="Author">

//SLShutdown.exe is a shutdown command from the application



Source: Windows Questions