Well i am new to Batch things, so need some help.
I understand the lowest level, but with more complicated things have problems.
Thing that i need now is File that launches other files, but with period of 30 secs or so.

Open Calculator
after 30 secs
Open Skype
after 30 secs
Open Notepad

How can i make this in a batch file? Preferably it should not show the CMD window.

Also if you can explain How the time things work it would be really nice.

  • 2
    Use the resources available on ss64.com/nt and try to learn form them. – Doktoro Reichard Aug 31 '13 at 20:40
  • Virtually any vintage DOS book cover batch command and batch files extensively. I suggest getting one of them and start reading. – user539484 Aug 31 '13 at 20:52
  • 1
    If you can't understand the sleep command then obviously you do not 'understand the lowest level'. This truly is the simplest batch file you could ever make and all you need to make it is knowing what commands are available. Doktoro has been kind enough to give you the command list, I've been kind enough to tell you the specific command. All that is left is for you to find out how to execute a programme without waiting for it to exit. You have everything you need, try to use that knowledge first then come back if you have problems. – Mokubai Aug 31 '13 at 20:58
  • Show your work so far, we are here to help not do the work. Also, batch is nearing dead. I would invest in PowerShell if you do not have a specific reason to learn batch. – Austin T French Aug 31 '13 at 20:59
  • Op: check this tread stackoverflow.com/questions/1672338/… – Frank Thomas Aug 31 '13 at 21:09

Without any additional software installed, use a normal Ping command to add delays

ping -n <delay_in_seconds> localhost 
start calc
ping -n <delay_in_seconds> localhost
start notepad
  • The parameter -n XX stands for how many pings should be executed, not for how long should be waited until next command. The delay between two pings is normally 1 second. In your example, you want to add 30 x 1s delays with ping -n 30 localhost

  • With localhost as ping destination you ping your own machine since we do not really want to send and receive a ping package

  • Suppress the CMD output with @echo off or localhost > nul

Without any additional software installed, you can utilize VBscripts Run method to run and hide batch files while executing. If you set "intWindowStyle" to 0, the Window is hidden.

object.Run(strCommand, [intWindowStyle], [bWaitOnReturn]) 

Create a new text file at the same folder as your batch file and save it as HiddenStart.vbs.
Paste the following two lines and replace <batch_file> with your actual batch file name. Prepend a path if the batch file isn't at the same folder.

Set wShell = CreateObject ("Wscript.Shell") 
wShell.Run "cmd /c <batch_file>", 0

Beside 0 as second parameter you can also use one of the following Window states

0   Hides the window and activates another window.
1   Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. 
2   Activates the window and displays it as a minimized window. 
3   Activates the window and displays it as a maximized window. 
4   Displays a window in its most recent size and position. The active window remains active.
5   Activates the window and displays it in its current size and position.
6   Minimizes the specified window and activates the next top-level window in the Z order.
7   Displays the window as a minimized window. The active window remains active.
8   Displays the window in its current state. The active window remains active.
9   Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. 
10  Sets the show-state based on the state of the program that started the application.

In the end you will have two files: A VBS file to start a hidden CMD and the CMD itself which starts your programs with custom delays.

enter image description here

  • Does not hide console window. – Vlastimil Ovčáčík Sep 1 '13 at 9:34
  • @VlastimilOvčáčík Now it does – nixda Sep 1 '13 at 9:37

start calc.exe
sleep 30

start "" "C:\Program Files\Skype\skype.exe"
sleep 30

start notepad.exe
  • It will wait until Calculator is closed, then wait 30 seconds. – gronostaj Aug 31 '13 at 21:02
  • @gronostaj: of course it does, thanks for pointing out the trivial mistake. – Vlastimil Ovčáčík Aug 31 '13 at 21:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.