From Windows 7 admin account I've set up a scheduled task with max privileges that executes a .cmd file which executes
shutdown -s -f -t 120
if the user happens to be logged in and its past their allowed hours.
The user has only user rights but he still can cancel my Admin enforced shutdown by typing in Run box
shutdown -a.
How do I prevent user from canceling and Admin issued shutdown? UAC is enabled. Thanks.
My final .cmd is this:
@echo off
for /f "delims=" %%? in ('tasklist /v^| findstr /B /C:"explorer.exe"') do call :USERis %%?
:USERis
echo/%*|find "username">nul 2>&1&&(set "liet=username")
echo/%*|find "Administrator">nul 2>&1&&(set "liet=Administrator")
echo/%liet%
if %liet%==username (
msg /server:localhost * /time:120 "Computer is shutting down in 2 minutes!"
timeout /T 120
shutdown -s -f -t 0 -c "Computer is shutting down!"
) else (
echo Admin logged in!
echo Do nothing
exit
)
exit
It is scheduled to run repeatedly every 3 minutes during 8 hour period when the PC should be off limits for user. So even if the PC is restarted it still gets a shutdown if User is logged in. Bios has setup password, time & date cannot be changed from user profile. Didn't check if BIOS boot menu works (to boot Linux and change time). Users are Linux dumb though.