![]() |
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 |
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 |
This works in a batch file for me:
"C:\Program Files\Mozilla Firefox\firefox.exe" "http://www.google.com" edit: clarity |
Thanks guys, both options work :D 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 :( |
put a start at teh begining of the line
start explorer "www.google.com" or the same for the other one |
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.
|
Quote:
|
did you try leading the line with 'start' ?
|
Yup, in ever case, leading with start seemed to have no bearing on the batches behavior.
|
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.
|
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. |
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:
i have no clue why you have so many Pipes "|" in your code either. |
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" |
firefox is my default browser and running "explorer http://www.google.com" opens up IE...
I think his pipes are line breaks in his batch file. |
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 |
That's it! Works perfectly now with the cd\ command to the directory then starting the executable.
Thanks ever so much sir. |
ahahaha finaly...
well glad i could help. |
All times are GMT -8. The time now is 07:07 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project