# Can anyone help me to create a simple bat file?



## otentik (Sep 4, 2003)

Hello there,
I was just asking myself how to write a script to launch several programs with a single click...
I ended up with...
cd program files
cd icq
icq.exe

cd..
cd yahoo
cd messenger
ypager.exe

cd..
cd..
cd msn messenger
msnmsgr.exe

cls

but, it dont really work...could anyone help me?
thanx!


----------



## brushmaster1 (Jun 15, 2002)

Try using the "call" function to open each program...


----------



## MarlinG (Aug 15, 2003)

specify quotes around paths with spaces:

c:
cd "\program files\icq"
icq.exe

--or just--

"c:\program files\icq\icq.exe"


----------



## AbvAvgUser (Oct 3, 2002)

DOS is used to file name of 8 characters max and .bat files are run under DOS. Is that the problem here? Check that.

May be for "Program Files", you will have to write "progra~1" and not in this way with a space. Ditto for all other longer file/folder names.


----------



## Shadow2531 (Apr 30, 2001)

"c:\program files\msn messenger\msnmsgr.exe"
"c:\program files\yahoo!\messenger\ypager.exe"
"c:\program files\icq\icq.exe"

That will work, but the second line won't get executed till you close out of msn messenger. Then the third line won't get executed till you minimize yahoo messenger or close it out.

No load detection I guess.

Normally loading multiple files at once works on problem, but with the IMs I guess it doesn't.

You could always uses c++ to accomplish what you want.


----------



## Shadow2531 (Apr 30, 2001)

If you have win2k/xp/2K3 it takes 1 line of code.


```
cmd /k "c:\program files\msn messenger\msnmsgr.exe" | "c:\program files\yahoo!\messenger\ypager.exe" | "c:\program files\icq\icq.exe"
```
Even though that works, it's an improper way to make it work. You will get an error after all 3 load. They will load fine, but you just get a pipe error.

you can try cmd /c instead and you shouldn't see the error, but the dos window will stay open till you close the programs.


----------



## Shadow2531 (Apr 30, 2001)

Finally. Here's the easy way.

"c:\program files\msn messenger\msnmsgr.lnk"
"c:\program files\yahoo!\messenger\ypager.lnk"
"c:\program files\icq\icq.lnk"

In each directory, right-click on the exe file and "create shortcut". then edit the name of the shortcut to get rid of the ".exe"

So instead of using the batch file to execute each program, you need to use the batch file to execute each shortcut that points to the program.

Then everything will work fine; even in win98.


----------



## MarlinG (Aug 15, 2003)

silly me...

try this:

start "c:\program files\msn messenger\msnmsgr.exe"
start "c:\program files\yahoo!\messenger\ypager.exe"
start "c:\program files\icq\icq.exe"


----------



## Shadow2531 (Apr 30, 2001)

@MarlinG

I myself couldn't get that to work. However using your example, I got it to work with the following code.

```
start /b cmd /c "c:\program files\msn messenger\msnmsgr.exe"
start /b cmd /c "c:\program files\yahoo!\messenger\ypager.exe"
start /b cmd /c "c:\program files\icq\icq.exe"
```
the b switch stops 3 separate windows from appearing and the cmd /c actually executes the line instead of displaying it.


----------



## otentik (Sep 4, 2003)

Well thanx a lot, i finally ended with...

@echo off
cd program files\icq
start icq.exe
cd..
cd yahoo\messenger
start ypager.exe
cd..
cd MSN Messenger
start msnmsgr.exe
cd..
cd internet explorer
start iexplore forums.techguy.org
cls

and it works all fine

now...only one small question...just after lauching the batch file...a dos-prompt will flash on the screen...does anyone knows how to get rid of this...
i have already tried /start min, but still it would flash...
let me know if this can be avoided

thanx again
otentik


----------



## Shadow2531 (Apr 30, 2001)

type start /? to see all the command switches.

start /min will start the window minimized.

If it still flashes, then it would be better to just accomplish the task with c++.


----------



## MarlinG (Aug 15, 2003)

fyi... the start command can also be used to open web pages directly:

start http://www.ibm.com

Shadow... not sure why you had to launch with /B through a another process (cmd.exe). I have noticed that if your command line doesnt specify a valid image then an empty cmd prompt opens. But command like these work ok (at least on my win2k):

start c:\windows\system32\notepad.exe
start c:\windows\system32\calc.exe


----------



## Shadow2531 (Apr 30, 2001)

That launches 2 different windows for me. 
I'm running Server 2K3 though.

start c:\windows\system32\notepad.exe
start c:\windows\system32\calc.exe

That will open 2 separate windows.

The first window will display 
start c:\windows\system32\notepad.exe

and the second window will display 
start c:\windows\system32\calc.exe

That's why I had to use what I said.

Server 2k3 should be the same as XP when it comes to cmd.exe, but might be slightly different than 2K and of course different to win98.

I used to use win98 and win2k, but don't have them handy for testing at the moment, but still offered suggestions that would help.


----------

