02-07-2005, 10:18 PM | #1 (permalink) |
Addict
Location: Texas
|
Opening URL via batch file
Pulling my hair out here. As part of a batch file, I'd like to open up a browser to a specific webpage. Now, at a command line, for both firefox and ie, you can type "c:\(program directories)\(browser executable) http://www.tfproject.org" and it will open the browser up a ok to the page. The second I slap it in the batch file, though, the whole thing decides it won't work. I've tried it alone too, in various forms, and it's a no go. From trial and error, it seems like the culprit might be the space between the executable and the url. quotes, no quotes, cd\(directory) then (command), I can't get anything to work. Argh!! Any insight?
ps, this is xp
__________________
" ' Big Mouth. Remember it took three of you to kill me. A god, a boy, and, last and least, a hero.' " |
02-07-2005, 11:30 PM | #2 (permalink) |
Devils Cabana Boy
Location: Central Coast CA
|
it is feeding it to explorer when you use the run command, in a batch file it is a bit difrent, call explorer and feed the URL as an argument.
Code:
explorer http:\\www.google.com
__________________
Donate Blood! "Love is not finding the perfect person, but learning to see an imperfect person perfectly." -Sam Keen |
02-08-2005, 10:05 AM | #4 (permalink) |
Addict
Location: Texas
|
Thanks guys, both options work Going with spindles just cause it matches the rest of the file nicely. You guys rock!
edit: and now I've got one more minor problem with this thing. I can't get the cmd.exe window to close at the end of starting all of the files (it wants to stay open until I CLOSE all of the files for some reason). I'm using a really sloppy format that looks like "c:\program"|"c:\program"|etc. I initialy tried having seperate lines, but the batch would pause after each program, waiting for me to close the one it opened before starting the new one. Probably something easy here, but I haven't touched .bats since dos 6.0 really. And every time I google I'm not getting the answers
__________________
" ' Big Mouth. Remember it took three of you to kill me. A god, a boy, and, last and least, a hero.' " Last edited by Pellaz; 02-08-2005 at 10:17 AM.. |
02-08-2005, 06:46 PM | #5 (permalink) |
Devils Cabana Boy
Location: Central Coast CA
|
put a start at teh begining of the line
start explorer "www.google.com" or the same for the other one
__________________
Donate Blood! "Love is not finding the perfect person, but learning to see an imperfect person perfectly." -Sam Keen |
02-08-2005, 09:00 PM | #6 (permalink) |
I am not permanent.
Location: Tennessee
|
If you want to keep using your existing structure and just make the batch file close after running the commands, simply but the exit command at the end.
__________________
If you're flammable and have legs, you are never blocking a fire exit. - Mitch Hedberg |
02-08-2005, 09:10 PM | #7 (permalink) | |
Addict
Location: Texas
|
Quote:
__________________
" ' Big Mouth. Remember it took three of you to kill me. A god, a boy, and, last and least, a hero.' " |
|
02-09-2005, 09:01 AM | #10 (permalink) |
Devils Cabana Boy
Location: Central Coast CA
|
start is designed to open the command in a new window, so that the original cna close when it finishes. can i see your code.
__________________
Donate Blood! "Love is not finding the perfect person, but learning to see an imperfect person perfectly." -Sam Keen |
02-09-2005, 09:21 AM | #11 (permalink) |
Addict
Location: Texas
|
Due to NDA stuff and the fact that I know some members of TFP definately fall under it's protection, I can't list the exact code, but this is the gist of it:
Code:
"c:\Program Files\PROGRAM" "C:\Program Files\REFERNCE FILE TO OPEN IN PROGRAM"|"c:\Program Files\PROGRAM"|"c:\Program Files\PROGRAM"|"c:\Program Files\Mozilla Firefox\firefox.exe" "http://URL" Sorry if I'm being incredibly obtuse here edit: It's just the start| that causes the new window to open. The |exit on the end shows no change if it's there or not, regardless of if start| is at the begining.
__________________
" ' Big Mouth. Remember it took three of you to kill me. A god, a boy, and, last and least, a hero.' " Last edited by Pellaz; 02-09-2005 at 09:25 AM.. |
02-09-2005, 02:43 PM | #12 (permalink) |
Devils Cabana Boy
Location: Central Coast CA
|
why do you referance firefox? if it is the default browser it should use it. besides that
let me try and understand what you want. 1st you want to open a file in a program, then you want to open a URL in browser here we go: Code:
start %SystemRoot%\system32\notepad.exe c:\1.txt start explorer http:\\google.com i have no clue why you have so many Pipes "|" in your code either.
__________________
Donate Blood! "Love is not finding the perfect person, but learning to see an imperfect person perfectly." -Sam Keen |
02-09-2005, 03:18 PM | #13 (permalink) |
Addict
Location: Texas
|
Thanks for your patience and help Dilbert, I appreciate it.
The pipes are there because the information I was able to find on my own suggested that as a way to start multiple processes via a batch. The sample with the pipes in it does everything I want to a T except closing the cmd.exe window, and every other method I tried I couldn't get to work even that well. As per your suggestion, I tried this one: Code:
start "path1.exe" "file" start "c:\Path2.exe" start "c:\Path3.exe" start explorer URL
__________________
" ' Big Mouth. Remember it took three of you to kill me. A god, a boy, and, last and least, a hero.' " |
02-09-2005, 03:55 PM | #15 (permalink) |
Devils Cabana Boy
Location: Central Coast CA
|
I mistyped that, it should be
start http:\\URL that will start with the default browser. Ok I think I got it this time. Before you execute the program change the directory to the directory that contains it. It seems like it is finicky with quotes. Ie Cd “c:\path to the file\” Start file.exe Cd c:\path to other file\” Start otherfile.exe
__________________
Donate Blood! "Love is not finding the perfect person, but learning to see an imperfect person perfectly." -Sam Keen |
02-09-2005, 04:05 PM | #16 (permalink) |
Addict
Location: Texas
|
That's it! Works perfectly now with the cd\ command to the directory then starting the executable.
Thanks ever so much sir.
__________________
" ' Big Mouth. Remember it took three of you to kill me. A god, a boy, and, last and least, a hero.' " |
Tags |
batch, file, opening, url |
|
|