Sleep when no one is logged on.
Hi.I'm trying to figure out how to make a PowerShell script that will put my computer to sleep when no one is logged on.We are 5 regular users of the samepc that often want it to remain running when we are away from the pc, but if no one is logged on there is no reason for it to run.So how do I make a PowerShell script that runs when no user are logged on and puts the pc to sleep after 5 minutes after the last user has logged off. It will ofcause have to take remote connected users into account also.Regards John.
October 23rd, 2009 11:01am
As I know there is only one way. You can create a batch file with the following contents.
shutdown /lrundll32 powrprof.dll,SetSuspendState
After you launch this batch file the computer will immediate sleep and log off.
Please note that you need to disable Hibernate with the following command. Otherwise the computer will Hibernate instead of Sleep after you launch the batch file.
Powercfg h off
Additionally, you need to make sure that there are no programs that can affect the logoff process. Otherwise the sleep process will be interrupted.Arthur Xie - MSFT
Free Windows Admin Tool Kit Click here and download it now
October 24th, 2009 6:15am


