Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
hi i want to run a browser iam using following code

C#
Shell("firefox" & " " & """" & "http://google.com" & """", AppWinStyle.NormalFocus, True, 1)


it is giving error file not found
Posted

Try using Process.Start[^]
 
Share this answer
 
Comments
srilekhamenon 1-Mar-12 8:51am    
no it is not working
error The system cannot find the file specified
[no name] 1-Mar-12 9:08am    
Have you specified the full path to the executable?
srilekhamenon 2-Mar-12 0:57am    
yes i have specified full path and now it is working fine, Thanks Sir
For launching a default browser you need to just call ShellExecute as shown below

ShellExecute(NULL, "open", "http://www.microsoft.com", NULL, NULL, SW_SHOWNORMAL);
 
Share this answer
 
Comments
srilekhamenon 1-Mar-12 8:41am    
your code will execute default browser but i want the specified browser argument also
 
Share this answer
 
Comments
srilekhamenon 2-Mar-12 0:59am    
it is working fine, Thanks
You have to supply the fully qualified path the FireFox.exe. Firefox is not going to be found in the PATH environment variable, so you're going to have to tell the machine where to find it.
 
Share this answer
 
So you want to call a specified browser with arguments..
For that you can query registry location: HKLM\Software\Clients\StartMenuInternet"
and get the list of installed browser in the machine.
Then for the specified browser you have to query HKLM\Software\Clients\StartMenuInternet\<Browser>\shell\open\command"
This will provide installed path of the specified browser.
Now by using this installed path you can call shellExecute as shown below.
C#
ShellExecute(NULL, L"open", <BrowserInstalledPath>, <ParametersToBrowser>, NULL, SW_SHOWNORMAL);

Suppose we need to call Google Chrome which will open www.yahoo.com, then shellexecute will be
C#
ShellExecute(NULL, L"open", L"C:\\Users\\chandrakant\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe", L"www.yahoomail.com", NULL, SW_SHOWNORMAL);
 
Share this answer
 
v2
Comments
srilekhamenon 2-Mar-12 0:59am    
it is working fine, Thanks but now i want this to be work in background or minimise mode my code is
Shell(C:\Program Files\Mozilla Firefox\firefox.exe" & " " & """" & "http://google.com" & """", AppWinStyle.Hide, True, 1)
Chandrakantt 2-Mar-12 1:14am    
You want that Firefox launched should be in minimized mode or be in background? Am I correct?
srilekhamenon 2-Mar-12 1:29am    
yes
<pre lang="vb"> System.Diagonstics.Process.Start("firefox.exe" "google.com")</pre>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900