Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Shutdown PC w/ batch file (1hour) after program(game) launched

29 Mar 2011   #1

Windows 7 x64
 
 
Shutdown PC w/ batch file (1hour) after program(game) launched

Is it possible to do this? I want to make it so that a game shuts down the computer after "X" seconds/minutes/hours of playing the game. But i want the file to be somewhat undetected. I don't want it popping up with a message saying things like "PC will shutdown in 3 minutes" or anything like that i just want it to have an auto shutdown or restart as if it had a virus or something was wrong with the PC.

I know batch files can do something like this so if you guys knew a little something to help me out thanks very much for your input

Just a little prank I'm pulling and your help would be great.
My System SpecsSystem Spec
29 Mar 2011   #2

 

(i'm too lazy to create the .bat today)

Use the Remote Shutdown Tool to Shutdown, Restart, or Logoff a Local or Networked Computer — MAXIMUMpcguides – Windows Vista tips, tricks, help, and how-to guides

Create the .bat file with options you want, info in the link.

Then once you're done... Modify the Game's shortcut icon to point to the .bat file... keep the original .ico in place so it looks like they're launching the game... As long as you have rights to the machine, this will do what you want.
My System SpecsSystem Spec
29 Mar 2011   #3

Microsoft Community Contributor Award Recipient

Windows 7 x64
 
 

I think you'd have a lot more luck dealing with the task scheduler for something like this.
Schedule a task
My System SpecsSystem Spec
.


29 Mar 2011   #4

Windows 7 x64
 
 

this is what i have right now.

@echo off

rem Notepad
cd C:\Program Files\game
start game.exe
exit

but how do i make it shut down? where do i add the -s -t 600?
My System SpecsSystem Spec
29 Mar 2011   #5

Microsoft Community Contributor Award Recipient

Windows 7 x64
 
 

Shutdown -s -t 3600

3600 seconds should be one hour.
My System SpecsSystem Spec
29 Mar 2011   #6

Windows 7 x64
 
 

okay so i got it working but how do i get rid of the warning?
My System SpecsSystem Spec
29 Mar 2011   #7

Microsoft Community Contributor Award Recipient

Windows 7 x64
 
 

I believe adding the /f or /p modifier will both remove the user notification.
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

shutdown /?
Usage: shutdown [/i | /l | /s | /r | /g | /a | /p | /h | /e] [/f]
[/m \\computer][/t xxx][/d [p|u:]xx:yy [/c "comment"]]

No args Display help. This is the same as typing /?.
/? Display help. This is the same as not typing any options.
/i Display the graphical user interface (GUI).
This must be the first option.
/l Log off. This cannot be used with /m or /d options.
/s Shutdown the computer.
/r Shutdown and restart the computer.
/g Shutdown and restart the computer. After the system is
rebooted, restart any registered applications.
/a Abort a system shutdown.
This can only be used during the time-out period.
/p Turn off the local computer with no time-out or warning.
Can be used with /d and /f options.
/h Hibernate the local computer.
Can be used with the /f option.
/e Document the reason for an unexpected shutdown of a computer.
/m \\computer Specify the target computer.
/t xxx Set the time-out period before shutdown to xxx seconds.
The valid range is 0-315360000 (10 years), with a default of 30.
If the timeout period is greater than 0, the /f parameter is
implied.
/c "comment" Comment on the reason for the restart or shutdown.
Maximum of 512 characters allowed.
/f Force running applications to close without forewarning users.
The /f parameter is implied when a value greater than 0 is
specified for the /t parameter.

/d [p|u:]xx:yy Provide the reason for the restart or shutdown.
p indicates that the restart or shutdown is planned.
u indicates that the reason is user defined.
If neither p nor u is specified the restart or shutdown is
unplanned.
xx is the major reason number (positive integer less than 256).
yy is the minor reason number (positive integer less than 65536).
My System SpecsSystem Spec
29 Mar 2011   #8

Windows 7 x64
 
 

@echo off


cd C:\Program Files\game
start game.exe
shutdown -s -p -f -t 10
exit


this is what im tryin to use but the computer doesnt shut down. how should i structure this for it to work?
My System SpecsSystem Spec
29 Mar 2011   #9

Microsoft Community Contributor Award Recipient

Windows 7 x64
 
 

The switches are different format it this way
shutdown /p -s -t 10

including both p and f seems redundant just try one then the other until you get the behavior you want.
My System SpecsSystem Spec
29 Mar 2011   #10

Windows 7 x64
 
 

okay thanks also, how about shutting a network computer down?

shutdown /m \\cool_computer /s

should that work?
My System SpecsSystem Spec
Reply

Thread Tools



Similar help and support threads for2: Shutdown PC w/ batch file (1hour) after program(game) launched
Thread Forum
Batch file: how to start a program [sidebar.exe] Performance & Maintenance
Batch file to run 10,000 instances of a program, in groups of 32 General Discussion
Batch program to fix 'File did not start with JPEG marker' Music, Pictures & Video
Solved Batch File that grabs file names from folder to insert into batch file General Discussion
Batch file to de-fragment, backup, then shutdown? General Discussion
batch file open file for program in the startup folder General Discussion
Solved Auto shutdown batch file help General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 12:05 PM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33