I am facing an issue in making the custom protocol handler to launch IE behave correctly.
Here is what i am trying to do:
I have my webpage that that users are required to access in chrome. The page has links to some external web-applications. These external web-applications work well only on Internet Explorer.
I have to somehow launch IE with the url of the external web-app on click of the link.
The customer is not open to utilizing plugins like IETab for launching these external applications.
Hence, i have tried to define a custom protocol handler which would get the target URL as a parameter and launch the internet explorer browser with the target URL.
It seems to work fine as long as there is no IE window already open. But behaves differently when there is already an instance of IE running.
I used the following code:
In the HTML file:
function launchIE(target){
window.location = "launchIE:\"http://external.url.com?param1=1¶m2=2\"";
}
I have registered the handler to the custom protocol "launchIE" by adding the following into windows registry:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\launchIE]
"URL Protocol"="\"\""
#="\"URL:launchIE Protocol\""
[HKEY_CLASSES_ROOT\launchIE\DefaultIcon]
#="\"iexplore.exe,1\""
[HKEY_CLASSES_ROOT\launchIE\shell]
[HKEY_CLASSES_ROOT\launchIE\shell\open]
[HKEY_CLASSES_ROOT\launchIE\shell\open\command]
#="cmd /C set myvar=%1 & call set myvar=%%myvar:launchIE:=%% & call start /separate iexplore %%myvar%% & exit"
With the above setup, when i click the button to trigger the above javascript I get Internet Explorer launched.
The IE opens the URL http://external.url.com?param1=1¶m2=2 correctly if there is no instance of Internet Explorer already open.
screenshot of IE showing correct URL
But, if there is already an instance of IE opened (either manually by the user or due to a prior click on the button on my page), IE opens an incorrect URL http://%22http//external.url.com?param1=1¶m2=2"
screenshot of IE showing wrong URL
Please help ... how should i fix this ?
I am working on windows 10 & IE 11.
I resolved it by creating a separate batch file, and surrounding the URL with double quotes:
[HKEY_CURRENT_USER\Software\Classes\ie\shell\open\command]
#="cmd /C c:/tmp/ie.bat \"%1\" & exit"
ie.bat:
set var=%1
set var=%var:ie:=%
call start /separate iexplore %var%
exit
Related
I have a Spring Boot application with only api rest calls.
Everytime I press the "run on server" button a browser is launched trying to access the current file. Of course it always prompt an error:
Sorry for the image being in Spanish. It basically says that cannot download the resource.
My question is how to avoid this browser from launching everytime I run my application.
Thanks.
I found the solution to my problem. Here is what I did:
Go to Window > Preferences > General > Web Browser > New...
Add a new browser with:
name = NO BROWSER (or whatever you want)
location = C:\Windows\System32\cmd.exe
parameters = /c
Press OK.
Finally select Use external web browser, select the browser we just added and press Apply and Close.
The browser configuration should look like this.
Instead of using the cmd you could use a batch/shell script that does nothing (without the /c parameter which is only needed for the cmd to do nothing).
NOTE: This solution is applied to the IDE not to the project.
Ok, I've read here and here that is not possible, on a gerneral browser, to force a link to be opened in IE.
So my question is: can I do it with a desktop launcher?
Extended question: Can I easily create a desktop launcher on Windows (10, 7 and maybe older versions) that if double clicked opens a specific URL in IE?
You can create a batch file to run the command to open IE with a specific url. You can create a .bat file and put the following code in the file:
start iexplore "http://www.bing.com"
Double click the .bat file, then it will open IE with Bing website.
Result:
I have a batch file that does a bunch of things and at the end needs to open up a web browser to a page. Is there a way to, in essence, call ShellExecute on a http to open the web page?
Windows Command Prompt
You can use the start command to do much the same thing as ShellExecute. For example
start "" http://www.stackoverflow.com
This will launch whatever browser is the default browser, so won't necessarily launch Internet Explorer.
1.To run from the default browser, use
start http://www.stackoverflow.com
Please make sure that the appropriate browser is set as default at Control Panel-> default program :
2.To launch page from specific browser, one can use
start "iexplore.exe" http://www.stackoverflow.com
start "chrome.exe" http://www.stackoverflow.com
start "firefox.exe" http://www.stackoverflow.com
Unfortunately, the best method to approach this is to use Internet Explorer as it's a browser that is guaranteed to be on Windows based machines. This will also bring compatibility of other users which might have alternative browsers such as Firefox, Chrome, Opera..etc,
start "iexplore.exe" http://www.website.com
When you use the start command to a website it will use the default browser by default but if you want to use a specific browser then use start iexplorer.exe www.website.com
Also you cannot have http:// in the url.
hh.exe (help pages renderer) is capable of opening some simple webpages:
hh http://www.nissan.com
This will work even if browsing is blocked through:
HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer
start did not work for me.
I used:
firefox http://www.stackoverflow.com
or
chrome http://www.stackoverflow.com
Obviously not great for distributing it, but if you're using it for a specific machine, it should work fine.
Is it possible to launch an application from a browser? I am not talking about opening a file from a browser (like open a PDF with Adobe Reader), but rather opening a new (blank) instance of an application that is installed on the user's machine.
Hypothetical situation: User browses a website that lists computers that can be managed via RDP. He clicks on a link to 192.168.1.10, that link opens Microsoft RDP client (mstsc.exe) with that ip address already filled out.
I am talking strictly about Windows universe.
Is that thing even doable outside of ActiveX and IE?
Is it wise to attempt this in IE with ActiveX?
The correct method is to register your custom URL Protocol in windows registry as follows:
[HKEY_CLASSES_ROOT\customurl]
#="Description here"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\customurl\shell]
[HKEY_CLASSES_ROOT\customurl\shell\open]
[HKEY_CLASSES_ROOT\customurl\shell\open\command]
#="\"C:\\Path To Your EXE\\ExeName.exe\" \"%1\""
Once the above keys and values are added, from the web page, just call "customurl:\\parameter1=xxx¶meter2=xxx" . You will receive the entire url as the argument in exe, which you need to process inside your exe. Change 'customurl' with the text of your choice.
You can't really "launch an application" in the true sense. You can as you indicated ask the user to open a document (ie a PDF) and windows will attempt to use the default app for that file type. Many applications have a way to do this.
For example you can save RDP connections as a .rdp file. Putting a link on your site to something like this should allow the user to launch right into an RDP session:
Server 1
#AbhijithCR 's reply works well. To register the protocol via a .bat file, do something like this
set key=customurl
reg add HKCR\%key% /ve /d "URL:Description"
reg add HKCR\%key% /v "URL Protocol" /d ""
reg add HKCR\%key%\shell
reg add HKCR\%key%\shell\open
reg add HKCR\%key%\shell\open\command /ve /d ""c:\path to\your.exe" ""%%1"""
For me getting all the quotes and the double percent signs right was the tricky part.
Some applications launches themselves by protocols. like itunes with "itms://" links. I don't know however how you can register that with windows.
We use a sonicwall vpn. It launches a java applet that launches mstc with all the credentials setup. You really can't do this without a java applet or activex plugin.
Microsoft uses this technique itself on their small business server for getting inside the network. I wouldn't say it is a terrible idea, as long as platform independence isn't important.
You can use SilverLight to launch an application from the browser (this will work only on IE and Firefox, newer versions of chrome don't support this)
Example code here
I achieved the same thing using a local web server and PHP. I used a script containing shell_exec to launch an application locally.
Alternatively, you could do something like this:
Notepad
How can I determine the Windows default browser (at the top of the start menu)?
I am using VB6 but can probably adapt other code no problem.
There are similar questions on Stack Overflow, but they seem to provide incorrect answers.
For instance the key HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\ lists both Internet Explorer and Firefox on my PC.
And getting the .html association fails for me as well, as HTML files are associated with IE but Firefox is my default browser.
Note that I don't want to actually open the browser, just get it's name.
When you click on a .html file, the browser that opens it is the one that has registered the .html extension.
When you open a http:// link (e.g. by typing it into the "Start->Run" box), the browser that opens is the one that has registered the HTTP protocol (although it's usually the same browser in both cases).
Whatever is displayed in Start Menu is not related to this.
HKEY_CURRENT_USER\Software\Classes\http\shell\open\command\(Default) is the current user's handler for the HTTP protocol (which means "default browser"; NOTE: this is NOT the same thing as the .html default handler!).
However, it is possible to have a different browser at the top of Start Menu without changing the default. FYI, the browser executable name in Start menu is stored in HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\(Default).
Tested in Windows 7 x64:
This is a two step process. The user's default browser is in key:
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice\Progid
Common browser Key Name:
IE: IE.AssocFile.HTM
FireFox: FirefoxHTML
Chrome: ChromeHTML
Opera: Opera.HTML
Replace <KEY NAME> below with one of the values above to find the executable:
HKCR\<KEY NAME>\shell\open\command
Autohotkey script to display the default browser path and executable:
MsgBox % "Default browser: " Browser()
Browser()
{
; Find the Registry key name for the default browser
RegRead, BrowserKeyName, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice, Progid
; Find the executable command associated with the above Registry key
RegRead, BrowserFullCommand, HKEY_CLASSES_ROOT, %BrowserKeyName%\shell\open\command
; The above RegRead will return the path and executable name of the brower contained within qoutes and optional parameters
; We only want the text contained inside the first set of quotes which is the path and executable
; Find the ending quote position (we know the beginning quote is in position 0 so start searching at position 1)
StringGetPos, pos, BrowserFullCommand, ",,1
; Decrement by one for the StringMid to work correctly
pos := --pos
; Extract and return the path and executable of the browser
StringMid, BrowserPathandEXE, BrowserFullCommand, 2, %pos%
Return BrowserPathandEXE
}
Default browsers are usually set on a per user basis. Have you tried HKEY_CURRENT_USER instead? Shows up on mine under there correctly.
reg QUERY HKEY_CLASSES_ROOT\htmlfile\shell\open\command /ve
you'll get something like
HKEY_CLASSES_ROOT\htmlfile\shell\open\command
(Default) REG_SZ "C:\Program Files\Internet Explorer\iexplore.exe" %1