Ever in need to lock your computer via batch file script?
On Windows 7 and Windows 8 this can be done within just a
few lines of batch file script.
The script can be set using the task scheduler and run the
batch file script at specified time.
The script will give an option to the user to abort or to
continue locking down the pc or workstation.
Choice to abort or continue is within 5 seconds. Of course
the time can be changed to any desired time.
After 5 seconds, user will need to press Ctrl + C to abort
the script and is given 10 seconds.
The script will continue to lock the computer if not
aborted.
This could be useful on a scenario where the user always
leave the desk, or for unmanaged computer that needs to be lock at a specified
time.
Here's the piece of code snippet using batch file script to
lock the computer:
@echo off
echo "This computer will be lock within 15 seconds,
Enter your choice within 5 seconds. Press "a" to abort "c"
to continue.."
choice /c ac /n /t 5 /d a
if %errorlevel%==1 goto :exit
if %errorlevel%==2 goto :CONTINUE
:exit
timeout /t 10 /nobreak
:Continue
rundll32.exe user32.dll, LockWorkStation
Good morning
ReplyDeleteThank you for you help script works great
I changed the time to 2 seconds