Windows 7 Forums Search
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows 7. The Windows 7 forum also covers news and updates and has an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7 - Run .BAT file prior to Shut Down?

 
01-07-2012   #1


Windows 7 Ultimate x64 SP1, LinuxMint 9 LTS x64, Debian 6, Ubuntu 10.04 LTS x64
 
 

Run .BAT file prior to Shut Down?

G'day,

I'm trying to find out if it is possible to use Task Scheduler to run a .BAT file (for backing up data) and then shut the PC down as soon as I click the Start Orb > Shut Down button.

Essentially, I want to use the Shut Down button as a trigger to invoke the .BAT file, and then for the PC to shut down once the .BAT file has completed.

I've searched a few tutorials, and looked at the Task Scheduler help, but I can't find out how to do this. Can anyone offer any suggestions?

Regards,
Golden

My System SpecsSystem Spec
01-07-2012   #2


Windows 7 Ultimate x64 SP1
 
 


Hello Golden,

It may be easier to create a BAT file to do the backup and shut down the computer after X amount of time when it's ran instead. This way you could create a shortcut of the BAT file, and pin it to say the taskbar to make it easy to use.

Hope this helps some,
Shawn
My System SpecsSystem Spec
01-07-2012   #3


windows 7 premium 64 bit
 
 


you need windows pro or greater , start /run "gpedit.ms"

"Local Computer Policy" User Configuration\Windows Settings\Scripts \logoff
My System SpecsSystem Spec
.


01-07-2012   #4


Windows Server 2008 R2
 
 


Yup - use a computer shutdown script. Given your specs say you're using Windows 7 Ultimate, you should be able to do this in gpedit under Computer Config > Windows Settings > Scripts.
My System SpecsSystem Spec
01-12-2012   #5


Windows 7 Ultimate x64 SP1, LinuxMint 9 LTS x64, Debian 6, Ubuntu 10.04 LTS x64
 
 


Guys,

Apologies for not replying sooner ... I've been playing with Linux for a bit.

Unfortunately, I forgot to mention that this is for a system running Home Premium, so I can't use the GPEDIT route and will have to go the shutdown route in the .BAT as suggested by Brink. Just one more question:

If I implement the following:

Code:
xcopy E:\Data\*.xlsx Z:\Backups\*.xlsx
shutdown /s
Will shutdown only be executed once the xcopy has been completed entirely? I'm inclined to think so, since its a batch file, and commands are executed sequentially. Or, is it safer to run:

Code:
xcopy E:\Data\*.xlsx Z:\Backups\*.xlsx
shutdown /t:60
Thanks,
Golden
My System SpecsSystem Spec
01-12-2012   #6


windows 7 premium 64 bit
 
 


if you use something like autoit you can use a runwait and youll get be able to use yout first code and even have the code copy the files you need with no worry about timing,

your first bat will work and execute after it copy's

Last edited by dsk04; 01-12-2012 at 02:12 PM..
My System SpecsSystem Spec
01-13-2012   #7


Windows 7 Ultimate x64 SP1, LinuxMint 9 LTS x64, Debian 6, Ubuntu 10.04 LTS x64
 
 


Thanks, I've tested both options for shutdown, and both work as expected.

Regards,
Golden
My System SpecsSystem Spec
Reply

 Run .BAT file prior to Shut Down? problems?



Thread Tools



Similar Threads for: Run .BAT file prior to Shut Down?
Thread Forum
How to get the open this file message to shut up? Software
Prior drive - sharing Hardware & Devices
PPPoE Prior to Login Network & Sharing
Quick solution to the "USB in use, shut it down prior" General Discussion
questions prior to upgrading Installation & Setup


All times are GMT -5. The time now is 06:43 PM.



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
  

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