1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Batch Files in XP

Discussion in 'Software' started by Fergal1982, Jan 16, 2005.

  1. Fergal1982

    Fergal1982 Petabyte Poster

    4,196
    171
    211
    Ok guys. i want to create a batch file which i can have sitting on my desktop and run to launch several applications (im lazy, what can i say).

    Now, using cd [directory] on one line, and the full name of the program on another, i can, as a general rule, make the program launch.

    but the problem is that the batch program tends to hang. after launching the program but before progressing to the next command. It doesnt do this consistently on the same program either.

    Any suggestions????

    Fergal
     
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present
  2. nugget
    Honorary Member

    nugget Junior toady

    7,796
    71
    224
    Hi Fergal, could you post the code so we can see what you're trying to do.
     
    Certifications: A+ | Network+ | Security+ | MCP (270,271,272,290,620) | MCDST | MCTS:Vista
    WIP: MCSA, 70-622,680,685
  3. Fergal1982

    Fergal1982 Petabyte Poster

    4,196
    171
    211
    OK. The program address isnt exact, as im currently at work but:

    Code:
    echo
    cd c:\program files\...\office10
    office.exe /recycle
    cd c:\program files\mozilla\...\
    firefox.exe
    cd c:\program files\trillian\...\
    trillian.exe
    exit
    i have tried just
    Code:
    c:\...\office.exe /recycle
    etc, but that didnt work, i even tried
    Code:
    Start c:\...\office.exe
    but that just loaded another cmd window labelled with the address.

    Fergal
     
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present
  4. SimonV

    SimonV Petabyte Poster Administrator

    6,616
    149
    228
    For MS Word you can use:

    Code:
    start WINWORD.EXE
    and if you wnat multiple programs just add them on the next line (ie):
    Code:
    start WINWORD.EXE
    start iexplore.EXE
    One particular use of the START command is to launch the default browser and go directly to a URL, for example: START http://google.com

    You may use any of four command line parameters with the START command. These go after the word START, but before the program name:

    /minimized or /m
    /maximized or /max
    /restored or /r
    /wait or /w
     
    Certifications: MOS Master 2003, CompTIA A+, MCSA:M, MCSE
    WIP: Keeping CF Alive...
  5. Fergal1982

    Fergal1982 Petabyte Poster

    4,196
    171
    211
    these arent standard windows programs though. would that work? do i not need to enter the specific address? and usually what happens is that it will load the first program, then hang and not load the others! though it doesnt matter which order the programs are in!

    Fergal
     
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present
  6. Phoenix
    Honorary Member

    Phoenix 53656e696f7220 4d6f64

    5,726
    175
    221
    you might wanna try

    echo Starting App 1
    start /wait c:\path\app1.exe /switch /anotherswitch

    echo Starting App 2
    start /wait c:\path\app2.exe /switch /anotherswitch

    echo Starting App 3
    start /wait c:\path\app3.exe /switch /anotherswitch


    exit
     
    Certifications: MCSE, MCITP, VCP
    WIP: > 0
  7. Fergal1982

    Fergal1982 Petabyte Poster

    4,196
    171
    211
    CAN I ASK, why the /wait??? basically i want to load outlook, firefox, and trillian (a chat program) from a single click on an icon in the quick launch bar, as i generally always load them all together (like i said, im lazy).

    Fergal
     
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present
  8. Phoenix
    Honorary Member

    Phoenix 53656e696f7220 4d6f64

    5,726
    175
    221
    the /wait commands tellst the batch file to wait till the command has been processed before moving in, this is even more useful when installing stuff, as it will wait for one program to install before moving onto the next one

    its useful in this instance as we have all seen the outcome of hitting ten icons together and the slowdown/lag it causes to our system, this shouldnt create much of a slow down, but it will ensure the batch file doesnt try to process the whole lot in one go

    you can try removing them as you see fit and experiment
     
    Certifications: MCSE, MCITP, VCP
    WIP: > 0
  9. Fergal1982

    Fergal1982 Petabyte Poster

    4,196
    171
    211
    Success. finally got it figured out!

    The final code is:

    Code:
    @ECHO OFF
      
      ECHO STARTING FIREFOX
      START C:\"Program Files"\"Mozilla Firefox"\firefox.exe
      
      ECHO STARTING TRILLIAN
      START C:\"Program Files"\Trillian\trillian.exe
      
      ECHO STARTING OUTLOOK
      START C:\"Program Files"\"Microsoft Office"\Office10
     \OUTLOOK.EXE  /recycle
    Note the quotation marks around program files. the batch file wont accept it if you dont (doh!).

    Fergal
     
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present
  10. n00bkilla

    n00bkilla New Member

    1
    0
    1
    Anytime you are writing a batch and have spaces within a path/filename, you must use parentheses...
    Your method works, but the normal method is "C:\Program Files\Mozilla Firefox\firefox.exe" /switches

    Using the /wait command is pointless as it renders the start command useless. Basically it forces it to wait until the program finishes (i.e. you close the program; the same as running an .exe without start as you did in your first attempt) to resume the batch file commands.

    I would recommend (depending on which and how many programs you would like to run) using a staller. Let the batch file stall for a few seconds before it finishes the command. Here is an example:

    Code:
    title Optional Startup Programs
    @echo off
    c:
    cd\
    cls
    
    ::-------------------------------------------------------------------------------------
    ::Gather User Input
    ::-------------------------------------------------------------------------------------
    
    
    set ffchoice=
    echo Do you want to start FireFox? (Y/N/ALL/Exit)
    set /p ffchoice=
    if %ffchoice% == exit exit
    if %ffchoice% == all (
    	set ffchoice=y
    	set olchoice=y
    	goto loadprog
    )
    
    set olchoice=
    echo Do you want to start Outlook? (Y/N/Exit)
    set /p olchoice=
    if %olchoice% == exit exit
    
    cls
    
    ::-------------------------------------------------------------------------------------
    ::Begin Loading Programs Chosen by User
    ::-------------------------------------------------------------------------------------
    :loadprog
    
    if %ffchoice% == y (
    	echo Starting Mozilla FireFox. Please Wait.....
    	start "FireFox" /min "C:\Program Files\Mozilla Firefox\firefox.exe"
    
    	echo Loading FireFox.
    	ping localhost -n 2 >nul
    	cls
    	echo Loading FireFox..
    	ping localhost -n 2 >nul
    	cls
    	echo Loading FireFox...
    	ping localhost -n 2 >nul
    	cls
    	echo Loading FireFox....
    	ping localhost -n 2 >nul
    	cls
    	echo Loading FireFox.....
    	ping localhost -n 2 >nul
    	cls
    	echo Loading FireFox......
    	ping localhost -n 2 >nul
    	cls
    	echo Loading FireFox.......
    	ping localhost -n 2 >nul
    	cls
    	echo Loading FireFox........
    	ping localhost -n 2 >nul
    	cls
    	echo Loading FireFox.........
    	ping localhost -n 2 >nul
    	cls
    	echo Loading FireFox..........
    	ping localhost -n 2 >nul
    	echo.
    	echo.
    	echo DONE!
    	ping localhost -n 3 >nul
    	cls
    )
    
    if %olchoice% == y (
    	echo Starting Outlook. Please Wait.....
    	start "Outlook" /min "C:\Program Files\Microsoft Office\Office12\outlook.exe" /recycle
    
    	echo Loading Outlook.
    	ping localhost -n 2 >nul
    	cls
    	echo Loading Outlook..
    	ping localhost -n 2 >nul
    	cls
    	echo Loading Outlook...
    	ping localhost -n 2 >nul
    	cls
    	echo Loading Outlook....
    	ping localhost -n 2 >nul
    	cls
    	echo Loading Outlook.....
    	ping localhost -n 2 >nul
    	cls
    	echo Loading Outlook......
    	ping localhost -n 2 >nul
    	cls
    	echo Loading Outlook.......
    	ping localhost -n 2 >nul
    	cls
    	echo Loading Outlook........
    	ping localhost -n 2 >nul
    	cls
    	echo Loading Outlook.........
    	ping localhost -n 2 >nul
    	cls
    	echo Loading Outlook..........
    	ping localhost -n 2 >nul
    	cls
    	echo Loading Outlook...........
    	ping localhost -n 2 >nul
    	cls
    	echo Loading Outlook............
    	ping localhost -n 2 >nul
    	cls
    	echo Loading Outlook.............
    	ping localhost -n 2 >nul
    	cls
    	echo Loading Outlook..............
    	ping localhost -n 2 >nul
    	echo.
    	echo.
    	echo DONE!
    	ping localhost -n 3 >nul
    	cls
    )
    
    exit
    I use something similar to this script with a few more progs added on... so use it if it fits you and add as necessary.

    Hope it helps someone...
     
  11. wizard

    wizard Petabyte Poster

    5,763
    35
    174
    Just a little pointer, the last reply to this thread was over 3 years ago :wink:
     
    Certifications: SIA DS Licence
    WIP: A+ 2009
  12. skulkerboyo

    skulkerboyo Megabyte Poster

    552
    19
    74
    Lol nearly spat my coffee on my monitor

    I'm off to find some ancient resolved threads that I can resolve:hahaha
     
    Certifications: MCITP:SA, MCSA 03, MCSA 08, MCTS(680+648),A+,N+,ITILV3 Foundation, ITIL Intermediate: Operational Support and Analysis
    WIP: 70-417

Share This Page

Loading...