Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › Help creating simple batch file
New Posts  All Forums:Forum Nav:

Help creating simple batch file

post #1 of 10
Thread Starter 
Hi, I would like to create a batch file which executes the following command in cmd prompt:

shutdown /s /t 3600

I really have no clue where to start.

Thanks.
My System
(19 items)
 
  
CPUMotherboardGraphicsRAM
Core i7-7700k Asus Maximus IX Hero EVGA GTX 1080 Ti 16GB Corsair Vengeance LED 3200 
Hard DriveHard DriveHard DriveHard Drive
Samsung 960 Evo NVme Corsair Neutron GTX 240GB Mushkin Chronos 480GB Toshiba 1TB 
Hard DriveCoolingOSMonitor
OCZ Vertex 3 120GB NZXT Kraken X62 Windows 10 x64 Pro Dell S2716DG 
KeyboardPowerCaseMouse
Corsair K90 Corsair AX850 NZXT S340 Elite White Steelseries Rival 
Mouse PadAudio
Razer Goliathus Asus Xonar STX 
  hide details  
Reply
My System
(19 items)
 
  
CPUMotherboardGraphicsRAM
Core i7-7700k Asus Maximus IX Hero EVGA GTX 1080 Ti 16GB Corsair Vengeance LED 3200 
Hard DriveHard DriveHard DriveHard Drive
Samsung 960 Evo NVme Corsair Neutron GTX 240GB Mushkin Chronos 480GB Toshiba 1TB 
Hard DriveCoolingOSMonitor
OCZ Vertex 3 120GB NZXT Kraken X62 Windows 10 x64 Pro Dell S2716DG 
KeyboardPowerCaseMouse
Corsair K90 Corsair AX850 NZXT S340 Elite White Steelseries Rival 
Mouse PadAudio
Razer Goliathus Asus Xonar STX 
  hide details  
Reply
post #2 of 10
I think I know what you mean...

Hold the Windows Button, and press R (which is the same as Start>>RUN)
Then type notepad.exe (it will launch notepad)

then, type inside the file:

@echo off
shutdown /s /t 3600

click on SAVE AS,
save the file as FILE.BAT
as long as it is in .bat, it will be a batch file...

If you want it to start up automatically, put it in the startup folder of your, Start >>Programs>>startup
Edited by thiagocosta85 - 12/28/10 at 9:29pm
Super Athlon
(13 items)
 
Ultra Intel
(14 items)
 
 
CPUMotherboardGraphicsRAM
Athlon 64 FX-62 Windsor GIGABYTE GA-M59SLI-S5 AM2 ATI RADEON HD 5770 SUPER TALENT 4GB (4 x 1GB) 240-Pin DDR2 800 
Hard DriveOSMonitorKeyboard
SCSI 15000 RPM OS + 250GB 7200 SATA II Linux 9.10 Karmic Kaola EMPTY ATM Saitek Ultra 
PowerCaseMouseMouse Pad
750W cheap one Custom Made DYNEX DELL 
CPUMotherboardGraphicsRAM
Intel I7 2600K S 1155 046MHW 1 x GTX 980 8GB DDR3 Cas9 1866Mhz 
Hard DriveHard DriveCoolingOS
2x Vertex 3 Raid 0 2x TB Raid 0 Hitachi Storage Hydro H70 7 Ultimage + Linux Gutsy 7.10 
MonitorKeyboardPowerCase
VX2268WM Saitek Ultra 875 WATTS Alien Aurora R3 Modded 
MouseMouse Pad
G9X Xtrac RIPPER 
CPUMotherboardGraphicsRAM
PHENOM II X4 955 4.0 GHZ 790FX-GD70 GTX 480 8192 
Hard DriveOSMonitorKeyboard
2 SSD Vertex 2 @ Raid 0. 2 250HDD's @ Raid 0 1 350 Linux 7.10 Gutsy + Windows 7 Ultimate 64 Samsung 21.5 Saitek Ultra 
PowerCaseMouseMouse Pad
Thermaltake Black Widow W0319RU 850W ATX 12V v2.3 Thermaltake Armor A90 Black Steel DYNEX DELL 
  hide details  
Reply
Super Athlon
(13 items)
 
Ultra Intel
(14 items)
 
 
CPUMotherboardGraphicsRAM
Athlon 64 FX-62 Windsor GIGABYTE GA-M59SLI-S5 AM2 ATI RADEON HD 5770 SUPER TALENT 4GB (4 x 1GB) 240-Pin DDR2 800 
Hard DriveOSMonitorKeyboard
SCSI 15000 RPM OS + 250GB 7200 SATA II Linux 9.10 Karmic Kaola EMPTY ATM Saitek Ultra 
PowerCaseMouseMouse Pad
750W cheap one Custom Made DYNEX DELL 
CPUMotherboardGraphicsRAM
Intel I7 2600K S 1155 046MHW 1 x GTX 980 8GB DDR3 Cas9 1866Mhz 
Hard DriveHard DriveCoolingOS
2x Vertex 3 Raid 0 2x TB Raid 0 Hitachi Storage Hydro H70 7 Ultimage + Linux Gutsy 7.10 
MonitorKeyboardPowerCase
VX2268WM Saitek Ultra 875 WATTS Alien Aurora R3 Modded 
MouseMouse Pad
G9X Xtrac RIPPER 
CPUMotherboardGraphicsRAM
PHENOM II X4 955 4.0 GHZ 790FX-GD70 GTX 480 8192 
Hard DriveOSMonitorKeyboard
2 SSD Vertex 2 @ Raid 0. 2 250HDD's @ Raid 0 1 350 Linux 7.10 Gutsy + Windows 7 Ultimate 64 Samsung 21.5 Saitek Ultra 
PowerCaseMouseMouse Pad
Thermaltake Black Widow W0319RU 850W ATX 12V v2.3 Thermaltake Armor A90 Black Steel DYNEX DELL 
  hide details  
Reply
post #3 of 10
@echo off
shutdown /s /t 3600

Type it into notepad and save it under all files, as filename.bat
15" rMPB
(7 items)
 
  
CPUGraphicsRAMHard Drive
Intel i7-2820QM Intel Iris Pro DDR3-1600 PCIe Solid State Drive 
OSMonitorAudio
Mac OS X 10.9.4 Mavericks 2880x1800 15" Retina Display Focusrite 2i2 -> Beyerdynamic T50p 
  hide details  
Reply
15" rMPB
(7 items)
 
  
CPUGraphicsRAMHard Drive
Intel i7-2820QM Intel Iris Pro DDR3-1600 PCIe Solid State Drive 
OSMonitorAudio
Mac OS X 10.9.4 Mavericks 2880x1800 15" Retina Display Focusrite 2i2 -> Beyerdynamic T50p 
  hide details  
Reply
post #4 of 10
Thread Starter 
@echo off
shutdown /s /t 3600

Does not work, it just brings up a blank cmd prompt and nothing happens.
My System
(19 items)
 
  
CPUMotherboardGraphicsRAM
Core i7-7700k Asus Maximus IX Hero EVGA GTX 1080 Ti 16GB Corsair Vengeance LED 3200 
Hard DriveHard DriveHard DriveHard Drive
Samsung 960 Evo NVme Corsair Neutron GTX 240GB Mushkin Chronos 480GB Toshiba 1TB 
Hard DriveCoolingOSMonitor
OCZ Vertex 3 120GB NZXT Kraken X62 Windows 10 x64 Pro Dell S2716DG 
KeyboardPowerCaseMouse
Corsair K90 Corsair AX850 NZXT S340 Elite White Steelseries Rival 
Mouse PadAudio
Razer Goliathus Asus Xonar STX 
  hide details  
Reply
My System
(19 items)
 
  
CPUMotherboardGraphicsRAM
Core i7-7700k Asus Maximus IX Hero EVGA GTX 1080 Ti 16GB Corsair Vengeance LED 3200 
Hard DriveHard DriveHard DriveHard Drive
Samsung 960 Evo NVme Corsair Neutron GTX 240GB Mushkin Chronos 480GB Toshiba 1TB 
Hard DriveCoolingOSMonitor
OCZ Vertex 3 120GB NZXT Kraken X62 Windows 10 x64 Pro Dell S2716DG 
KeyboardPowerCaseMouse
Corsair K90 Corsair AX850 NZXT S340 Elite White Steelseries Rival 
Mouse PadAudio
Razer Goliathus Asus Xonar STX 
  hide details  
Reply
post #5 of 10
text in italics are the commands you need to type...

C:\\>copy con foo.bat
shutdown /s /t 50000
Hit F6 then Enter... you should see "^Z"
and " 1 file(s) copied."

now let's see if foo.bat is there...
C:\\>dir foo.bat

Volume in drive...

12/28/2010 11:23 PM 22 foo.bat
1 File(s) 22 bytes

C:\\>

Execute it by typing foo, or if you have multiple files with the same name foo.bat


C:\\>foo
and the batch runs the commands...
C:\\>shutdown /s /t 50000
and returns to the console...
C:\\>


Shutdown /a cancels the scheduled event...


If using notepad...

You need to change the Save As Type in notepad's save dialog to "Any *.*" or it will append the .txt file extension to whatever you name it, even something.bat will save as something.bat.txt


Echo off is to remove the display of text to the console, until you have the desired results i would not turn echo off...

also, the @ at the beginning of echo off... is a line based echo off... ie...

@echo off
foo

does the same thing as

@foo

so it's kind of a waste with one line...
Edited by LiNERROR - 12/28/10 at 9:37pm
Khaos
(14 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 @ 4.59ghz Asus P6T Gigabyte GTX 1080 48GB 6 x G.SKILL Ripjaws X 8GB DDR3 1866 
Hard DriveCoolingOSMonitor
28 x WD Blk 8TB Raid 6 on Areca 24 port SATA/SA... Xigmatek 1283EE 2016 Standard 3x 43" 4k 120hz 
KeyboardPowerCaseMouse
Ergodox Infinity 1.2b Dual 1200w P2 CM Stacker 810 Roccat Tyon 
Mouse PadAudio
48x16" deskmat SMSL AD18, Klipsch R-15M, xDuoo DAC, AKG K7XX 
  hide details  
Reply
Khaos
(14 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 @ 4.59ghz Asus P6T Gigabyte GTX 1080 48GB 6 x G.SKILL Ripjaws X 8GB DDR3 1866 
Hard DriveCoolingOSMonitor
28 x WD Blk 8TB Raid 6 on Areca 24 port SATA/SA... Xigmatek 1283EE 2016 Standard 3x 43" 4k 120hz 
KeyboardPowerCaseMouse
Ergodox Infinity 1.2b Dual 1200w P2 CM Stacker 810 Roccat Tyon 
Mouse PadAudio
48x16" deskmat SMSL AD18, Klipsch R-15M, xDuoo DAC, AKG K7XX 
  hide details  
Reply
post #6 of 10
well, I guess you have to wait 3600 seconds. 3600 seconds is how many minutes? 60 ..
Which means 1 hour ? ...

I think lol im bad in math...

But if u ran the code with 3600 in it, you need to wait 3600 seconds

Im sure the screen will dessapear, specialy in windows vista + ...

If you want to add a Pause to the end, it might stay...

so.

@echo off
shutdown /s /t 3600

pause

But it should shutdown even though it dessapears..

Why dont you try shutdown /s /t 30

see if it shuts down in 30 seconds

I never used the shutdown command in my life in windows OS, but ...
Maybe now that you ran it at 3600 you might have to wait? .. Idk...

Log off, just to be safe.
Edited by thiagocosta85 - 12/28/10 at 9:34pm
Super Athlon
(13 items)
 
Ultra Intel
(14 items)
 
 
CPUMotherboardGraphicsRAM
Athlon 64 FX-62 Windsor GIGABYTE GA-M59SLI-S5 AM2 ATI RADEON HD 5770 SUPER TALENT 4GB (4 x 1GB) 240-Pin DDR2 800 
Hard DriveOSMonitorKeyboard
SCSI 15000 RPM OS + 250GB 7200 SATA II Linux 9.10 Karmic Kaola EMPTY ATM Saitek Ultra 
PowerCaseMouseMouse Pad
750W cheap one Custom Made DYNEX DELL 
CPUMotherboardGraphicsRAM
Intel I7 2600K S 1155 046MHW 1 x GTX 980 8GB DDR3 Cas9 1866Mhz 
Hard DriveHard DriveCoolingOS
2x Vertex 3 Raid 0 2x TB Raid 0 Hitachi Storage Hydro H70 7 Ultimage + Linux Gutsy 7.10 
MonitorKeyboardPowerCase
VX2268WM Saitek Ultra 875 WATTS Alien Aurora R3 Modded 
MouseMouse Pad
G9X Xtrac RIPPER 
CPUMotherboardGraphicsRAM
PHENOM II X4 955 4.0 GHZ 790FX-GD70 GTX 480 8192 
Hard DriveOSMonitorKeyboard
2 SSD Vertex 2 @ Raid 0. 2 250HDD's @ Raid 0 1 350 Linux 7.10 Gutsy + Windows 7 Ultimate 64 Samsung 21.5 Saitek Ultra 
PowerCaseMouseMouse Pad
Thermaltake Black Widow W0319RU 850W ATX 12V v2.3 Thermaltake Armor A90 Black Steel DYNEX DELL 
  hide details  
Reply
Super Athlon
(13 items)
 
Ultra Intel
(14 items)
 
 
CPUMotherboardGraphicsRAM
Athlon 64 FX-62 Windsor GIGABYTE GA-M59SLI-S5 AM2 ATI RADEON HD 5770 SUPER TALENT 4GB (4 x 1GB) 240-Pin DDR2 800 
Hard DriveOSMonitorKeyboard
SCSI 15000 RPM OS + 250GB 7200 SATA II Linux 9.10 Karmic Kaola EMPTY ATM Saitek Ultra 
PowerCaseMouseMouse Pad
750W cheap one Custom Made DYNEX DELL 
CPUMotherboardGraphicsRAM
Intel I7 2600K S 1155 046MHW 1 x GTX 980 8GB DDR3 Cas9 1866Mhz 
Hard DriveHard DriveCoolingOS
2x Vertex 3 Raid 0 2x TB Raid 0 Hitachi Storage Hydro H70 7 Ultimage + Linux Gutsy 7.10 
MonitorKeyboardPowerCase
VX2268WM Saitek Ultra 875 WATTS Alien Aurora R3 Modded 
MouseMouse Pad
G9X Xtrac RIPPER 
CPUMotherboardGraphicsRAM
PHENOM II X4 955 4.0 GHZ 790FX-GD70 GTX 480 8192 
Hard DriveOSMonitorKeyboard
2 SSD Vertex 2 @ Raid 0. 2 250HDD's @ Raid 0 1 350 Linux 7.10 Gutsy + Windows 7 Ultimate 64 Samsung 21.5 Saitek Ultra 
PowerCaseMouseMouse Pad
Thermaltake Black Widow W0319RU 850W ATX 12V v2.3 Thermaltake Armor A90 Black Steel DYNEX DELL 
  hide details  
Reply
post #7 of 10
Thread Starter 
Quote:
Originally Posted by LiNERROR View Post
text in italics are the commands you need to type...

C:\\>copy con foo.bat
shutdown /s /t 50000
Hit F6 then Enter... you should see "^Z"
and " 1 file(s) copied."

now let's see if foo.bat is there...
C:\\>dir foo.bat

Volume in drive...

12/28/2010 11:23 PM 22 foo.bat
1 File(s) 22 bytes

C:\\>

Execute it by typing foo, or if you have multiple files with the same name foo.bat


C:\\>foo
and the batch runs the commands...
C:\\>shutdown /s /t 50000
and returns to the console...
C:\\>


Shutdown /a cancels the scheduled event...
Thanks, this worked.
My System
(19 items)
 
  
CPUMotherboardGraphicsRAM
Core i7-7700k Asus Maximus IX Hero EVGA GTX 1080 Ti 16GB Corsair Vengeance LED 3200 
Hard DriveHard DriveHard DriveHard Drive
Samsung 960 Evo NVme Corsair Neutron GTX 240GB Mushkin Chronos 480GB Toshiba 1TB 
Hard DriveCoolingOSMonitor
OCZ Vertex 3 120GB NZXT Kraken X62 Windows 10 x64 Pro Dell S2716DG 
KeyboardPowerCaseMouse
Corsair K90 Corsair AX850 NZXT S340 Elite White Steelseries Rival 
Mouse PadAudio
Razer Goliathus Asus Xonar STX 
  hide details  
Reply
My System
(19 items)
 
  
CPUMotherboardGraphicsRAM
Core i7-7700k Asus Maximus IX Hero EVGA GTX 1080 Ti 16GB Corsair Vengeance LED 3200 
Hard DriveHard DriveHard DriveHard Drive
Samsung 960 Evo NVme Corsair Neutron GTX 240GB Mushkin Chronos 480GB Toshiba 1TB 
Hard DriveCoolingOSMonitor
OCZ Vertex 3 120GB NZXT Kraken X62 Windows 10 x64 Pro Dell S2716DG 
KeyboardPowerCaseMouse
Corsair K90 Corsair AX850 NZXT S340 Elite White Steelseries Rival 
Mouse PadAudio
Razer Goliathus Asus Xonar STX 
  hide details  
Reply
post #8 of 10
Quote:
Originally Posted by LiNERROR View Post
Shutdown /a cancels the scheduled event...
Nice bro, even though i never used shutdown command in windows, I like the /a parameter ... =D

Super Nice
Super Athlon
(13 items)
 
Ultra Intel
(14 items)
 
 
CPUMotherboardGraphicsRAM
Athlon 64 FX-62 Windsor GIGABYTE GA-M59SLI-S5 AM2 ATI RADEON HD 5770 SUPER TALENT 4GB (4 x 1GB) 240-Pin DDR2 800 
Hard DriveOSMonitorKeyboard
SCSI 15000 RPM OS + 250GB 7200 SATA II Linux 9.10 Karmic Kaola EMPTY ATM Saitek Ultra 
PowerCaseMouseMouse Pad
750W cheap one Custom Made DYNEX DELL 
CPUMotherboardGraphicsRAM
Intel I7 2600K S 1155 046MHW 1 x GTX 980 8GB DDR3 Cas9 1866Mhz 
Hard DriveHard DriveCoolingOS
2x Vertex 3 Raid 0 2x TB Raid 0 Hitachi Storage Hydro H70 7 Ultimage + Linux Gutsy 7.10 
MonitorKeyboardPowerCase
VX2268WM Saitek Ultra 875 WATTS Alien Aurora R3 Modded 
MouseMouse Pad
G9X Xtrac RIPPER 
CPUMotherboardGraphicsRAM
PHENOM II X4 955 4.0 GHZ 790FX-GD70 GTX 480 8192 
Hard DriveOSMonitorKeyboard
2 SSD Vertex 2 @ Raid 0. 2 250HDD's @ Raid 0 1 350 Linux 7.10 Gutsy + Windows 7 Ultimate 64 Samsung 21.5 Saitek Ultra 
PowerCaseMouseMouse Pad
Thermaltake Black Widow W0319RU 850W ATX 12V v2.3 Thermaltake Armor A90 Black Steel DYNEX DELL 
  hide details  
Reply
Super Athlon
(13 items)
 
Ultra Intel
(14 items)
 
 
CPUMotherboardGraphicsRAM
Athlon 64 FX-62 Windsor GIGABYTE GA-M59SLI-S5 AM2 ATI RADEON HD 5770 SUPER TALENT 4GB (4 x 1GB) 240-Pin DDR2 800 
Hard DriveOSMonitorKeyboard
SCSI 15000 RPM OS + 250GB 7200 SATA II Linux 9.10 Karmic Kaola EMPTY ATM Saitek Ultra 
PowerCaseMouseMouse Pad
750W cheap one Custom Made DYNEX DELL 
CPUMotherboardGraphicsRAM
Intel I7 2600K S 1155 046MHW 1 x GTX 980 8GB DDR3 Cas9 1866Mhz 
Hard DriveHard DriveCoolingOS
2x Vertex 3 Raid 0 2x TB Raid 0 Hitachi Storage Hydro H70 7 Ultimage + Linux Gutsy 7.10 
MonitorKeyboardPowerCase
VX2268WM Saitek Ultra 875 WATTS Alien Aurora R3 Modded 
MouseMouse Pad
G9X Xtrac RIPPER 
CPUMotherboardGraphicsRAM
PHENOM II X4 955 4.0 GHZ 790FX-GD70 GTX 480 8192 
Hard DriveOSMonitorKeyboard
2 SSD Vertex 2 @ Raid 0. 2 250HDD's @ Raid 0 1 350 Linux 7.10 Gutsy + Windows 7 Ultimate 64 Samsung 21.5 Saitek Ultra 
PowerCaseMouseMouse Pad
Thermaltake Black Widow W0319RU 850W ATX 12V v2.3 Thermaltake Armor A90 Black Steel DYNEX DELL 
  hide details  
Reply
post #9 of 10
Thread Starter 
Yeah thanks for all the help.

I just wanted to make a folder which contained different files which shutdown in different times, e.g. 1 hour, 2 hour, 3 hour e.c.t. The cancel shutdown is a nice addition.
My System
(19 items)
 
  
CPUMotherboardGraphicsRAM
Core i7-7700k Asus Maximus IX Hero EVGA GTX 1080 Ti 16GB Corsair Vengeance LED 3200 
Hard DriveHard DriveHard DriveHard Drive
Samsung 960 Evo NVme Corsair Neutron GTX 240GB Mushkin Chronos 480GB Toshiba 1TB 
Hard DriveCoolingOSMonitor
OCZ Vertex 3 120GB NZXT Kraken X62 Windows 10 x64 Pro Dell S2716DG 
KeyboardPowerCaseMouse
Corsair K90 Corsair AX850 NZXT S340 Elite White Steelseries Rival 
Mouse PadAudio
Razer Goliathus Asus Xonar STX 
  hide details  
Reply
My System
(19 items)
 
  
CPUMotherboardGraphicsRAM
Core i7-7700k Asus Maximus IX Hero EVGA GTX 1080 Ti 16GB Corsair Vengeance LED 3200 
Hard DriveHard DriveHard DriveHard Drive
Samsung 960 Evo NVme Corsair Neutron GTX 240GB Mushkin Chronos 480GB Toshiba 1TB 
Hard DriveCoolingOSMonitor
OCZ Vertex 3 120GB NZXT Kraken X62 Windows 10 x64 Pro Dell S2716DG 
KeyboardPowerCaseMouse
Corsair K90 Corsair AX850 NZXT S340 Elite White Steelseries Rival 
Mouse PadAudio
Razer Goliathus Asus Xonar STX 
  hide details  
Reply
post #10 of 10
@echo off
shutdown -s -t 3600

Type it into notepad and save it under all files, as filename.bat

I don't know if this will work. But I know the last time I did it it worked with dashes not slashes.
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › Help creating simple batch file