Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is it possible to set Internet Explorer as the default browser to launch from the command line?

I have a web application that only runs under Internet Explorer, but if it happens that Firefox is the default browser, it doesn't work. Users are in a domain environment and even though I try to launch our application from a batch in this way:

start "C:\Program Files\Internet Explorer\iexplore.exe" http://server_ip/home_page

the application doesn't start unless I change the browser manually.

share|improve this question
4  
I suppose "fix the app so that it actually honors proper html instead of breaking under every decent browser" isn't an option? –  Shadur Feb 3 at 19:51
1  
@Shadur There are some spheres where problems are viewed as features.. –  josmh Feb 3 at 20:53
    
Relying on broken behavior specific to a single browser is not, or at least should never be, a feature. –  Shadur Feb 4 at 8:23
    
@techie007 I didn't test it myself but you can check out here and here. –  avirk Feb 7 at 2:50
    
Just drop the start to get the command to work. "C:\Program Files\Internet Explorer\iexplore.exe" http://server_ip/home_page –  Brian Feb 8 at 3:02
add comment

5 Answers

up vote 9 down vote accepted

This command will set IE as the default browser:

shmgrate.exe OcinstallreinstallIE

This policy should stop people determining the default browser.

share|improve this answer
    
Thank you very much :) –  nick rulez Jun 23 '11 at 18:56
    
No probs. Glad it worked out for you. –  slotishtype Jun 23 '11 at 22:30
    
+1 for the policy as well. –  MDT Guy Feb 3 at 19:18
    
In Windows Vista the registration scheme was overhauled. The shmgrate tool is only available in Windows 2000/XP and Windows Server 2003. Also, that policy will just prevent Internet Explorer from checking whether it's set as the default browser. –  and31415 Feb 8 at 16:01
add comment

you can try this, it will work

start "" "C:\Program Files\Internet Explorer\iexplore.exe" http://server_ip/home_page

the error in your command was that start expects first quoted string to be the title of the application, which in this case you can leave empty.

for setting iexplorer.exe as system's default web browser, you can use assoc and ftype commands, which associate extensions with file types, and file types with executable files, like so:

assoc .html=htmlfile
ftype htmlfile="C:\Program Files\Internet Explorer\iexplore.exe" %1

%1 is the argument here - that is the URL or the file that you can send to the program as an input

share|improve this answer
1  
(Just) Associating the HTML file type to be opened by IE is not the same as setting it to be the OS's default browser. –  techie007 Feb 5 at 17:21
add comment

Windows Vista and later, IE 7+

The following batch script simulates clicking Set this programs as default from the Default Programs control panel applet. Tested with Vista/7 and IE 7/IE 11.

@echo off
setlocal enabledelayedexpansion

REM -- check XHTML support (IE 9+)
set xhtml=0
for /f %%G in ('"reg query "HKCR\IE.AssocFile.XHT" /ve 2>&1 | findstr /c:".XHT" "') do set xhtml=1

REM -- reset file extensions
set exts=HTM,HTML
if %xhtml% == 1 (set exts=%exts%,XHT,XHTML)

for %%G in (%exts%) do (
set ext=%%G
set ext=!ext:~0,3!
reg add "HKCU\Software\Classes\.%%G" /ve /t REG_SZ /d "IE.AssocFile.!ext!" /f >nul
)

set exts=%exts%,MHT,MHTML,URL
set acl=%temp%\acl_%random%%random%.txt

for %%G in (%exts%) do (
set key=HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.%%G\UserChoice
echo !key! [1 7 17]>"%acl%"
regini "%acl%" >nul
set ext=%%G
set ext=!ext:~0,3!
reg add "!key!" /v "Progid" /t REG_SZ /d "IE.AssocFile.!ext!" /f >nul
)
del "%acl%" 2>nul

REM -- reset MIME associations
for %%G in (message/rfc822,text/html) do (
set key=HKCU\Software\Microsoft\Windows\Shell\Associations\MIMEAssociations\%%G\UserChoice
reg add "!key!" /v "Progid" /t REG_SZ /d "IE.%%G" /f >nul
)

REM -- reset URL protocols
for %%A in (FTP,HTTP,HTTPS) do (
set key=HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\%%A\UserChoice
reg add "!key!" /v "Progid" /t REG_SZ /d "IE.%%A" /f >nul
for %%B in (DefaultIcon,shell) do (
set key=HKCU\Software\Classes\%%A
reg delete "!key!\%%B" /f >nul 2>&1
reg copy "HKCR\IE.%%A\%%B" "!key!\%%B" /s /f >nul
reg add "!key!" /v "EditFlags" /t REG_DWORD /d 2 /f >nul
reg add "!key!" /v "URL Protocol" /t REG_SZ /d "" /f >nul
))

REM -- reset the start menu Internet link (Vista and earlier)
reg add "HKCU\Software\Clients\StartMenuInternet" /ve /t REG_SZ /d "IEXPLORE.EXE" /f

REM -- reset cached icons
if %xhtml% == 1 (
ie4uinit -cleariconcache
) else (
taskkill /im explorer.exe /f >nul
start explorer
)

pause
exit /b

Remarks

Any web browser application can register to appear as an Internet client on the Start menu. This visibility, coupled with proper registration for an application's file and protocol types, gives an application default browser status. The default web browser is used for launching arbitrary URLs from anywhere in the system.

Note Existing [start menu link] registrations are ignored in Windows 7 and later. This registration is deprecated as of Windows 7.

Source: How to Register an Internet Browser or Email Client With the Windows Start Menu

­­

The hierarchical registry structure for file and protocol associations gives precedence to per-user defaults over machine-level defaults.

Source: Default Programs

share|improve this answer
    
Doesn't reset IE as default for me on Windows 8.1. :( –  techie007 Feb 9 at 2:59
    
@techie007 What about the Default Programs settings in the control panel? Did anything change there? Did you get any errors while executing the batch script? –  and31415 Feb 9 at 11:10
    
Seems to works under Windows 7 (Pro, 64-bit), but under Windows 8 (Pro 32-bit) it just shows the (same/usual) output "The operation completed successfully." -- "Press any key to continue . . ." but doesn't actually set IE as the default. –  techie007 Feb 10 at 17:40
    
Under my other Windows 8 machine, it worked a little better. I run it, and then next time I open a http link, it asks me which browser I want to use. This is good enough by me, as other bits and pieces all seem (AFAICT) to think IE is registered as the default after doing that. So have my bounty. :) –  techie007 Feb 10 at 17:52
    
@techie007 I totally forgot that Microsoft has changed the rules and now there's an anti-tampering protection for most of those registry keys. If you're willing to test it, I can send you an updated version of the script which would just clear the association in Windows 8 and later so that the next time you open a link or a html file, Windows would let you choose which browser to use. That's probably the best you can achieve in an automated way because (some) user interaction would be required anyway. –  and31415 Feb 15 at 16:57
add comment

I don't know about setting the default browser from the command line, but you can set and enforce it for the domain via group policy.

Here's something to get you started:

http://technet.microsoft.com/en-us/library/hh147307%28WS.10%29.aspx

share|improve this answer
add comment

Just drop the start to get the command or batch file to work.

"C:\Program Files\Internet Explorer\iexplore.exe" http://server_ip/home_page
share|improve this answer
1  
We're (well I am anyway) looking for solutions on setting the default browser from the command-line, not just to solve the example problem/reason in the OP. –  techie007 Feb 8 at 5:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.