Got my question answered here -
This is the correct method. It is also robust in that it is unconditional. If you wish to have your cake and eat it then the Guest account must use a powerful "agent" to perform the shutdown task. A scheduled task would be such an agent. It could work like so:
- Create a scheduled task that runs Script1 to perform these tasks:
- Check if the file C:\Shutdown\Shutdown.txt exists.
- If it does not, exit from the script.
- If it does, delete Shutdown.txt.
- Check if there is a live Administrator session. If yes, exit from the script.
- If there is no live Administrator session, shut down the machine, using shutdown.exe.
- The task must run once every 3 minutes under an admin account.
- Create a desktop shortcut for the Guest user that invokes Script2 to perform these tasks:
- Check if there is a live Administrator session.
- If it does, create a pop-up to inform the user that the machine cannot be shut down.
- If it does not, create the file C:\Shutdown\Shutdown.txt. The scheduled task will "see" this file and will shut down the machine.