Computer Hope

Microsoft => Microsoft DOS => Topic started by: deathavenger13 on December 14, 2007, 09:06:56 AM

Title: .batch file problem
Post by: deathavenger13 on December 14, 2007, 09:06:56 AM
ok..i have a problem with a .batch file im running.... lets say i open "a.bat" the code i have so far is:
Code: [Select]
echo (
start iexplore.exe www.google.com
exit
)
>"a1.bat
start a1.bat
now i know this is wrong...i also tried
Code: [Select]
echo start iexplore.exe www.google.com|exit>"a1.bat
start a1.bat

..now before u start saying "just do 'start www.google.com'", i NEED to open google through this format, and be able to for future reference, and not just opening google...
thx all!
Title: Re: .batch file problem
Post by: Sidewinder on December 14, 2007, 09:37:51 AM
In the TV version of M*A*S*H, Major Charles Emerson Winchester said he did one thing at a time, did it very well and then moved on.

Words to live by. Don't try to do everything at once:

Code: [Select]
echo start iexplore.exe www.google.com > a1.bat
echo exit >> a1.bat

Once a1.bat is created, you can launch the program with start a1.bat

 8)
Title: Re: .batch file problem
Post by: deathavenger13 on December 15, 2007, 02:07:09 AM
thanks Sidewinder ;)! that really helped, and now it doesnt break anymore ;D
Title: Re: .batch file problem
Post by: deathavenger13 on December 17, 2007, 04:42:06 AM
I've come across another problem with this...
Code: [Select]
...
echo echo Hello World >> a1.bat
echo pause>nul >> a1.bat
...
appears to work fine, but when I call or start a1.bat it is just "pause" instead of "pause>nul". Is there anyway to get it to say "pause>nul" through the format above? And if not, is there anyway I can do this that is automated?
Thx!
Title: Re: .batch file problem
Post by: Sidewinder on December 17, 2007, 05:18:12 AM
Try using the escape character (^):

Code: [Select]
echo pause ^> nul >> a1.bat

 8)