Create a batch file,
schtasks /create /tn "sleep" /tr c:\scripts\sleep.bat /sc once /st %neartime% /ru System
rundll32 user32.dll,ExitWindowsEx
the first line creates a scheduled task that runs sleep.bat as system user 1 minute from now. The second line logs you of.
In the sleep.bat file you need to add the following line which will send the PC to sleep.
rundll32.exe powrprof.dll,SetSuspendState
In the first batch file you need to work out what time it will be 1 minute from now (%neartime%)
set curtime=%time%
set curhh=%curtime:~0,2%
set curhh=%curhh: =%
set curmm=%curtime:~3,2%
set curmm=%curmm: =%
if "%curmm:~0,1%" == "0" set curmm=%curmm:~1,1%
set /a nearmm=%curmm% + 2
set /a nearhh=%curhh%
if %nearmm% gtr 59 (
set /a nearmm=nearmm% - 60
SET /A nearhh=%nearhh% + 1
)
if %nearmm% gtr 59 if %nearhh% gtr 23 set /a nearhh=%nearhh% - 24
if %nearmm% lss 10 set nearmm=0%nearmm%
set neartime=%nearhh%:%nearmm%
This wont be instant but it will be automated.
Alternatively you could set you pc to lock when resuming from sleep, and then the sleep command on its own will lock the station (although this doesnt log you off, its close!)
And how do you suggest we use PsShutdown for that purpose? – AnT – 2013-03-26T17:08:19.847