Overclock.net banner

1 - 9 of 9 Posts

·
Registered
Joined
·
246 Posts
Discussion Starter · #1 ·
Hi everybody,

I am in need of some assistance creating a batch file/script to shutdown the computer after 2 hours of uptime w/o a prompt. I currently got it working but i always get this warning popup. Below is what I have so far:

@echo off
c:\windows\system32\shutdown -s -f -t 7200

Any help would be great,

TIA,
Jinx
 

·
Premium Member
Joined
·
10,773 Posts
There's no way to avoid the prompt when there is a time out specified. I can think of one way you can accomplish this and it will involve the Task Scheduler and a more advanced batch script. Here is the script:

Code:

Code:
@ECHO OFF
IF NOT EXIST "%TEMP%\shutdown.lock" (
  COPY NUL "%TEMP%\shutdown.lock"
  GOTO END
)

:SHUTDOWN
DEL "%TEMP%\shutdown.lock"
shutdown -s -t 0

:END
Save that script somewhere, e.g. C:\shutdown.bat

OK now you need to schedule a task. Fire up the Task Scheduler and create a new task (not basic task). Create a new trigger:



Next create a new action to run the batch script:



Save everything. This will run the task at logon and then every 2 hours after that. At first logon, the script does nothing except for create a file. The next time it runs (in 2 hours) it will notice the file was created, then it will delete it and shutdown the machine.
 

·
Registered
Joined
·
246 Posts
Discussion Starter · #6 ·
Not my request, I had to reformat a laptop for my friend and one of the request was to have a 2 hour uptime limit. I guess they are trying to limit their child's access to the computer
 

·
Premium Member
Joined
·
10,773 Posts
Quote:
Originally Posted by The Jinx View Post

Not my request, I had to reformat a laptop for my friend and one of the request was to have a 2 hour uptime limit. I guess they are trying to limit their child's access to the computer
Probably would have been better to use Windows' inbuilt parental controls
tongue.gif
 

·
Registered
Joined
·
501 Posts
Maybe the kid is doing some computer work and the shut down process does not save it properly (as it should) - write behind cache, for ex.
Some recommend using Group Policy (gpedit.msc) for the shutdown script: Computer Configuration/Windows Settings/Scripts (Startup/Shutdown): double click on Stop system.
 

·
Registered
Joined
·
246 Posts
Discussion Starter · #9 ·
yea i brought up that point, but they insisted a forced shutdown. I dont know why either.
 
1 - 9 of 9 Posts
Top