 |
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 Specs | | System Manufacturer/Model Number Golden Mk. I.3 OS Windows 7 Ultimate x64 SP1, LinuxMint 9 LTS x64, Debian 6, Ubuntu 10.04 LTS x64 CPU Intel i7 860 @ 2.80 GHz Motherboard Gigabyte P55A-UD3R Rev.1. Award BIOS F13 Memory 16GB Corsair Vengance DDR3 @ 661 MHz Dual Channel (9-9-9-24) Graphics Card EVGA NVidia GTX 560 1024MB Sound Card Realtek Integrated Monitor(s) Displays Dual Samsung SyncMaster 2494HS Screen Resolution 1920*1080 and 1920*1080 Keyboard Logitech G110 Mouse Logitech MX518 PSU Thermaltake ToughPower QFan 750W Case Thermaltake Element S VK60001W2Z Cooling Corsair H60 Water Cooling, 2*230mm and 2*80mm case fans Hard Drives 1*OCZ Vertex 2 60GB SSD;
2*Samsung F3 SpinPoint 1TB in RAID0;
2*Samsung F1 SpinPoint 1TB in RAID1;
1*Western Digital WD10EARS 1TB
1*Western Digital 500GB External USB 3.0
1*Seagate 500GB External USB 2.0 Internet Speed Not fast enough!!! |
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 Specs | | System Manufacturer/Model Number Self built custom OS Windows 7 Ultimate x64 SP1 CPU Intel i7-980X 3.3 Ghz (3.48 Ghz OC'd) Motherboard ASUS P6X58D Premium Memory 12 GB (2GBx6) DDR3 PC3-16000 2000 MHz Kingston HyperX Graphics Card Sapphire HD5870 Eyefinity 6 2GB Sound Card Realtek HD Audio ALC889 Integrated Chip Monitor(s) Displays 3x 27" Asus VE278Q Screen Resolution 1920x1080 Keyboard Logitech Cordless Desktop MX 5500 Revolution Mouse Logitech Cordless Desktop MX 5500 Revolution PSU OCZ Series Gold OCZZ1000M 1000W Case Corsair Obsidian 800D Cooling Thermalright Ultra 120 Extreme Copper CPU heat sink w/120 MM Hard Drives 160GB OCZ RevoDrive X2
** 2 x 1TB Samsung HDD HD154UI SATA Internet Speed 50 Mb/s Download and 2 Mb/s Upload Other Info Microsoft LifeCam Cinema
** Lite-On iHBS212 12x BD Writer
** Samsung CLX-3175FW Printer
** Netgear WNDR3800 Router
** Motorola SBG6580 Cable Modem
** 2x APC Back-UPS XS 1500 |
01-07-2012
|
#3 | | |
you need windows pro or greater , start /run "gpedit.ms"
"Local Computer Policy" User Configuration\Windows Settings\Scripts \logoff | My System Specs | | System Manufacturer/Model Number dell m5030 OS windows 7 premium 64 bit CPU AMD Athlon IIP360 Dual core 2.3ghz Memory 4GB PC3 Graphics Card ATI Mobility Radeon HD 4250 Monitor(s) Displays 15.6 inch Hard Drives 120gb Patriot PYRO |
01-07-2012
|
#4 | | |
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 Specs | | System Manufacturer/Model Number HP Z400 workstation OS Windows Server 2008 R2 CPU Intel Xeon 3550 @3.06GHz Motherboard HP Memory 16GB DDR3 Graphics Card Nvidia Quadro 600 Sound Card Realtek ALC262 Monitor(s) Displays 2x Hanns-G HG281 Screen Resolution 1920x1200 Keyboard Microsoft Natural Ergonomic Keyboard 7000 Mouse Microsoft Intellimouse Explorer 3.0 PSU HP Case HP Hard Drives 1x Samsung 160GB SSD
2x WD 1TB (RAID1) |
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 Specs | | System Manufacturer/Model Number Golden Mk. I.3 OS Windows 7 Ultimate x64 SP1, LinuxMint 9 LTS x64, Debian 6, Ubuntu 10.04 LTS x64 CPU Intel i7 860 @ 2.80 GHz Motherboard Gigabyte P55A-UD3R Rev.1. Award BIOS F13 Memory 16GB Corsair Vengance DDR3 @ 661 MHz Dual Channel (9-9-9-24) Graphics Card EVGA NVidia GTX 560 1024MB Sound Card Realtek Integrated Monitor(s) Displays Dual Samsung SyncMaster 2494HS Screen Resolution 1920*1080 and 1920*1080 Keyboard Logitech G110 Mouse Logitech MX518 PSU Thermaltake ToughPower QFan 750W Case Thermaltake Element S VK60001W2Z Cooling Corsair H60 Water Cooling, 2*230mm and 2*80mm case fans Hard Drives 1*OCZ Vertex 2 60GB SSD;
2*Samsung F3 SpinPoint 1TB in RAID0;
2*Samsung F1 SpinPoint 1TB in RAID1;
1*Western Digital WD10EARS 1TB
1*Western Digital 500GB External USB 3.0
1*Seagate 500GB External USB 2.0 Internet Speed Not fast enough!!! |
01-12-2012
|
#6 | | |
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 Specs | | System Manufacturer/Model Number dell m5030 OS windows 7 premium 64 bit CPU AMD Athlon IIP360 Dual core 2.3ghz Memory 4GB PC3 Graphics Card ATI Mobility Radeon HD 4250 Monitor(s) Displays 15.6 inch Hard Drives 120gb Patriot PYRO |
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 Specs | | System Manufacturer/Model Number Golden Mk. I.3 OS Windows 7 Ultimate x64 SP1, LinuxMint 9 LTS x64, Debian 6, Ubuntu 10.04 LTS x64 CPU Intel i7 860 @ 2.80 GHz Motherboard Gigabyte P55A-UD3R Rev.1. Award BIOS F13 Memory 16GB Corsair Vengance DDR3 @ 661 MHz Dual Channel (9-9-9-24) Graphics Card EVGA NVidia GTX 560 1024MB Sound Card Realtek Integrated Monitor(s) Displays Dual Samsung SyncMaster 2494HS Screen Resolution 1920*1080 and 1920*1080 Keyboard Logitech G110 Mouse Logitech MX518 PSU Thermaltake ToughPower QFan 750W Case Thermaltake Element S VK60001W2Z Cooling Corsair H60 Water Cooling, 2*230mm and 2*80mm case fans Hard Drives 1*OCZ Vertex 2 60GB SSD;
2*Samsung F3 SpinPoint 1TB in RAID0;
2*Samsung F1 SpinPoint 1TB in RAID1;
1*Western Digital WD10EARS 1TB
1*Western Digital 500GB External USB 3.0
1*Seagate 500GB External USB 2.0 Internet Speed Not fast enough!!! Run .BAT file prior to Shut Down? problems? All times are GMT -5. The time now is 06:43 PM. |  |