Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Software Development
Tag Cloud
access acer asus bios bsod computer crash drive driver drivers error ethernet excel freeze games gaming graphics hard drive hardware hdmi internet laptop malware memory monitor motherboard netgear network printer problem ram random registry router slow software sound trojan usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless xbox
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Software Development >
open multiple programs Batch file

Reply  
Thread Tools
becarta's Avatar
Junior Member with 8 posts.
 
Join Date: Dec 2008
Location: Netherlands - Zoetermeer
Experience: Advanced
01-Dec-2008, 06:45 AM #1
open multiple programs Batch file
Hello all. I made this code for opening programs easy
But it needs some improvement.

Now i can choose 1 number and it opens that number.
What i want is choose al the numbers you want separately by a , and that he opens al the programs
How can i do that ?
Code:
@echo off
cls

TITLE Programma's

echo 1)  Firefox
echo 2)  Msn    
echo 3)  Word
echo 4)  Cod 4 Rcon
echo 5)  Teamspeak
echo 6)  Xfire
echo 7)  Utorrent
echo 8)  Photoshop
echo 9)  Donut
echo 10) Teamviewer 3
echo 11) Windows Mobile Apperaten
echo x) Afsluiten
:a
set /p ans=Choose Your Program:

if '%ans%'== '1' GOTO Firefox
if '%ans%'== '2' GOTO Msn
if '%ans%'== '3' GOTO Word
if '%ans%'== '4' GOTO Cod 4 Rcon
if '%ans%'== '5' GOTO Teamspeak
if '%ans%'== '6' GOTO Xfire
if '%ans%'== '7' GOTO Utorrent
if '%ans%'== '8' GOTO Photoshop
if '%ans%'== '9' GOTO Donut
if '%ans%'== '10' GOTO Teamviewer
if '%ans%'== '11' GOTO WMApp
if '%ans%'== 'x' GOTO Afsluiten

GOTO a

:Firefox
cd "C:\Program Files\Mozilla Firefox\"
start firefox.exe
GOTO a

:Msn
cd "C:\Program Files\Windows Live\Messenger\"
start msnmsgr.exe

GOTO a

:Word
cd "C:\Program Files\Microsoft Office\Office12\"
start WINWORD.EXE

GOTO a

:Cod 4 Rcon
cd "C:\Program Files\ModernRcon\"
start ModernRcon_v0.8.exe

GOTO a

:Teamspeak
cd "C:\Program Files\Teamspeak2_RC2\"
start TeamSpeak.exe

GOTO a

:xfire
cd "C:\Program Files\Xfire\"
start xfire.exe

GOTO a

:Utorrent
cd "C:\Program Files\uTorrent\"
start uTorrent.exe

GOTO a

:Photoshop
cd "C:\Program Files\Adobe\Adobe Photoshop CS2"
start Photoshop.exe

GOTO a

:Donut
cd "C:\Users\Richard\Desktop\Progamma's"
start U.exe

GOTO a

:Teamviewer
cd "C:\Program Files\TeamViewer3\"
start TeamViewer.exe

GOTO a

:WMApp
cd "C:\Program Files\TeamViewer3\"
start TeamViewer.exe

GOTO a

:Aflsuiten
exit
-Fabez-'s Avatar
Senior Member with 1,943 posts.
 
Join Date: Jul 2008
Location: Earth
Experience: General
01-Dec-2008, 04:00 PM #2
The command prompt will wait for the first program to finish before it starts another one so it would be easier to use a higher level language such as Python in order to achieve this.
becarta's Avatar
Junior Member with 8 posts.
 
Join Date: Dec 2008
Location: Netherlands - Zoetermeer
Experience: Advanced
01-Dec-2008, 04:06 PM #3
I would like to make this in c++ but i dont have the knowledge for that. I will try python thats new for me.

thx for the response
-Fabez-'s Avatar
Senior Member with 1,943 posts.
 
Join Date: Jul 2008
Location: Earth
Experience: General
01-Dec-2008, 04:08 PM #4
Python is a brilliant high level language and I will be happy to help if you encounter any problems
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 9,048 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
03-Dec-2008, 03:43 PM #5
Quote:
Originally Posted by -Fabez- View Post
The command prompt will wait for the first program to finish before it starts another one
That's true if you call the program directly, but he's using Start. Using Start, it will only wait if you use the /wait switch.
Quote:
Originally Posted by becarta View Post
Code:
:Teamviewer
cd "C:\Program Files\TeamViewer3\"
start TeamViewer.exe

GOTO a

:WMApp
cd "C:\Program Files\TeamViewer3\"
start TeamViewer.exe
You are starting the same program for #10 and #11. I'm assuming a typo, so that will need to be corrected.

This will allow you to enter multiple program numbers at one time separated by commas. You can enter the x to exit at any point in the string, it will start all programs before exiting. Program numbers can be entered in any order, and will be started in the order entered.

This uses the trick that passing a variable containing a comma to another file or a subroutine without using quotes replaces the comma with a space.

Code:
@Echo off
cls

TITLE Programma's

Echo 1)  Firefox
Echo 2)  Msn    
Echo 3)  Word
Echo 4)  Cod 4 Rcon
Echo 5)  Teamspeak
Echo 6)  Xfire
Echo 7)  Utorrent
Echo 8)  Photoshop
Echo 9)  Donut
Echo 10) Teamviewer 3
Echo 11) Windows Mobile Apperaten
Echo x) Afsluiten
:a
Set /p ans=Choose Your Program:
Set eflag=0
Set ans=%ans: =%
Echo %ans% |Find /I ",">Nul
If %Errorlevel%==1 (Call :single %ans%) Else (call :multiple %ans%)
If %eflag%==1 Exit
Goto a
:single
If [%1]==[1] Start "C:\Program Files\Mozilla Firefox\firefox.exe"
If [%1]==[2] Start "C:\Program Files\Windows Live\Messenger\msnmsgr.exe"
If [%1]==[3] Start "C:\Program Files\Microsoft Office\Office12\WINWORD.EXE"
If [%1]==[4] Start "C:\Program Files\ModernRcon\ModernRcon_v0.8.exe"
If [%1]==[5] Start "C:\Program Files\Teamspeak2_RC2\TeamSpeak.exe"
If [%1]==[6] Start "C:\Program Files\Xfire\xfire.exe"
If [%1]==[7] Start "C:\Program Files\uTorrent\uTorrent.exe"
If [%1]==[8] Start "C:\Program Files\Adobe\Adobe Photoshop CS2\Photoshop.exe"
If [%1]==[9] Start "C:\Users\Richard\Desktop\Progamma's\U.exe"
If [%1]==[10] Start "C:\Program Files\TeamViewer3\TeamViewer.exe"
If [%1]==[11] Start "C:\Program Files\TeamViewer3\TeamViewer.exe"
If /I [%1]==[x] Set eflag=1
Goto :EOF
:multiple
If [%1]==[] Goto :EOF
Call :single %1
Shift
Goto :Multiple
HTH

Jerry
__________________
Microsoft MVP - Windows Expert - Consumer
Of course I know all the answers ; I just don't always match the answers to the right questions

becarta's Avatar
Junior Member with 8 posts.
 
Join Date: Dec 2008
Location: Netherlands - Zoetermeer
Experience: Advanced
04-Dec-2008, 05:07 AM #6
Hello TheOutcaste

I tryed your code but i have a question.
When i open a program whit my code it opens the program. you can see at this screen http://img20.imageshack.us/img20/4718/mineqm2.jpg

When i use you code it das this.
http://img392.imageshack.us/img392/3711/yourmw3.jpg

I tryed some things to make it work but no succes.
Mabye you know it


Edit :
I tryed in cmd to use Start "C:\Program Files\Xfire\xfire.exe" that is also not working.
But when i do this.
cd\Program Files\Xfire\ and then start xfire.exe it will start xfire.
So i think that 2 steps are needed.

Last edited by becarta; 04-Dec-2008 at 07:22 AM..
becarta's Avatar
Junior Member with 8 posts.
 
Join Date: Dec 2008
Location: Netherlands - Zoetermeer
Experience: Advanced
04-Dec-2008, 08:46 AM #7
Found the solution

Code:
@Echo off
cls 

TITLE Your Program

Echo 1)  Firefox
Echo 2)  Msn    
Echo 3)  Word
Echo 4)  Cod 4 Rcon
Echo 5)  Teamspeak
Echo 6)  Xfire
Echo 7)  Utorrent
Echo 8)  Photoshop
Echo 9)  Donut
Echo 10) Teamviewer 3
Echo 11) Windows Mobile Apperaten
Echo x) Afsluiten
:a
Set /p ans=Choose Your Program:
Set eflag=0
Set ans=%ans: =%
Echo %ans% |Find /I ",">Nul
If %Errorlevel%==1 (Call :single %ans%) Else (call :multiple %ans%)
If %eflag%==1 Exit
Goto a
:single
If [%1]==[1] cd\Program Files\Mozilla Firefox\
If [%1]==[1] start firefox.exe
If [%1]==[2] cd\Program Files\Windows Live\Messenger\
If [%1]==[2] start msnmsgr.exe
If [%1]==[3] cd\Program Files\Microsoft Office\Office12
If [%1]==[3] Start WINWORD.EXE
If [%1]==[4] cd\Program Files\ModernRcon\
If [%1]==[4] Start ModernRcon_v0.8.exe
If [%1]==[5] cd\Program Files\Teamspeak
If [%1]==[5] start TeamSpeak.exe
If [%1]==[6] cd\Program Files\Xfire\
If [%1]==[6] start xfire.exe
If [%1]==[7] cd\Program Files\uTorrent\
If [%1]==[7] start uTorrent.exe
If [%1]==[8] cd\Program Files\Adobe\Adobe Photoshop CS2\
If [%1]==[8] start Photoshop.exe
If [%1]==[9] cd\Users\Richard\Desktop\Progamma's\
If [%1]==[9] start U.exe
If [%1]==[10] cd\Program Files\TeamViewer3\
If [%1]==[10] start TeamViewer.exe
If [%1]==[11] cd\Windows\WindowsMobile\
If [%1]==[11] start wmdc.exe /show
If /I [%1]==[x] Set eflag=1
Goto :EOF
:multiple
If [%1]==[] Goto :EOF
Call :single %1
Shift
Goto :Multiple
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 9,048 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
04-Dec-2008, 11:12 AM #8
That's what I get for testing with Notepad.
Didn't have any of the other programs except Firefox on the PC yesterday, and didn't test with it for some reason
The Start command let's you specify the path by using the /D switch, so the following should work, at least it did with Firefox, MSN Messenger, and MS Word on another system.
I also added the /I switch, just in case other batch files are run before this one that may modify the environment.
I also changed it to use the %ProgramFiles% variable instead of hard coding the path, so it won't matter what drive your Program Files folder is actually on. (Unless a previous batch file changes that variable).
Code:
If [%1]==[1] Start /D /I "%ProgramFiles%\Mozilla Firefox\" firefox.exe
If [%1]==[2] Start /D /I "%ProgramFiles%\Windows Live\Messenger\" msnmsgr.exe
If [%1]==[3] Start /D /I "%ProgramFiles%\Microsoft Office\Office12\" WINWORD.EXE"
If [%1]==[4] Start /D /I "%ProgramFiles%\ModernRcon\" ModernRcon_v0.8.exe
If [%1]==[5] Start /D /I "%ProgramFiles%\Teamspeak2_RC2\" TeamSpeak.exe
If [%1]==[6] Start /D /I "%ProgramFiles%\Xfire\" xfire.exe
If [%1]==[7] Start /D /I "%ProgramFiles%\uTorrent\" uTorrent.exe
If [%1]==[8] Start /D /I "%ProgramFiles%\Adobe\Adobe Photoshop CS2\" Photoshop.exe
If [%1]==[9] Start /D /I "C:\Users\Richard\Desktop\Progamma's\" U.exe
If [%1]==[10] Start /D /I "%ProgramFiles%\TeamViewer3\" TeamViewer.exe
If [%1]==[11] Start /D /I "%windir%\WindowsMobile\" wmdc.exe /show
You can also combine the cd and start commands on the same line like this:
Code:
If [%1]==[1] cd /D C:\Program Files\Mozilla Firefox\ & start firefox.exe
The /D switch and drive letter would only be needed for the CD command if the batch file is run from another drive.

HTH

Jerry
__________________
Microsoft MVP - Windows Expert - Consumer
Of course I know all the answers ; I just don't always match the answers to the right questions

becarta's Avatar
Junior Member with 8 posts.
 
Join Date: Dec 2008
Location: Netherlands - Zoetermeer
Experience: Advanced
04-Dec-2008, 05:56 PM #9
Some time it wont work.
at this on

Quote:
If [%1]==[4] Start /D /I "%ProgramFiles%\ModernRcon\" ModernRcon_v0.8.exe
I get the error he cant find the path.
But what i have works and i want to give it a nice look. so i will give python a try when i know how it works
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 9,048 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
04-Dec-2008, 06:22 PM #10
Does it work using this:
Code:
If [%1]==[4] cd\Program Files\ModernRcon\
If [%1]==[4] Start ModernRcon_v0.8.exe
or this:
Code:
If [%1]==[4] "cd\Program Files\ModernRcon\" & Start ModernRcon_v0.8.exe
If so, it may be just that program is setting it's Working directory in a non-standard manner, and you can use one of the above for that program. You may want to make a bug report to the Author as well.

If those also give an error, then you need to double check that the file is actually in c:\Program Files\ModernRcon\

I'll have to download it and see if I get the same error. Might not work as I don't have COD though...

Jerry
__________________
Microsoft MVP - Windows Expert - Consumer
Of course I know all the answers ; I just don't always match the answers to the right questions

TheOutcaste's Avatar
Computer Specs
Distinguished Member with 9,048 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
04-Dec-2008, 06:36 PM #11
Remove the /I switch, then it should work. Don't know why, but that fixed it on my XP system.
Code:
If [%1]==[4] Start /D "%ProgramFiles%\ModernRcon\" ModernRcon_v0.8.exe
If there are other programs that fail, try that for them as well.
Jerry
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 04:34 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.