Solved

Set IE11 as default in Windows 10 (once)

Posted on 2016-11-10
9
68 Views
Last Modified: 2016-11-16
Hi all,

I need to make IE11 the default in Windows 10 for all staff.

The solutions Microsoft offer are not great and don't give us the flexability so I put together the below VBS script. This does work but I was wondering if it could either be managed better by powershell?

 If not I need help adding an option to create a registry key once the script has run once as the current user. On the next logon the script should then check if that value exists for that key and exit if it does.

Set WshShell = WScript.CreateObject("WScript.Shell")


' IE Default browser for WIN10
WshShell.Run "%windir%\system32\control.exe /name Microsoft.DefaultPrograms /page pageDefaultProgram\pageAdvancedSettings?pszAppName=Internet%20Explorer"

' Give Default Programs time to load
WScript.Sleep 1200

' WshShell.AppActivate "Set Program Associations"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys " "
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
'WScript.Sleep 500
WshShell.SendKeys " "

WScript.Quit

Open in new window


thanks
0
Comment
Question by:ranski
  • 5
  • 2
  • 2
9 Comments
 
LVL 5

Expert Comment

by:Austin Texas
ID: 41883296
What is wrong with just letting it run on logon everytime?
0
 

Author Comment

by:ranski
ID: 41883412
We want to allow staff who would prefer to use chrome the option of having that as the default. Our issue is that Edge doesn't support our internal systems.
0
 
LVL 54

Expert Comment

by:McKnife
ID: 41883500
Using sendkeys is prone to failure. It will try to act interactively and if the user uses the machine at the same time, it will fail.
I have not set a default browser on win10 using GPOs, but I know that we can assign all possible file types and protocols to IE. To do this, see an example for adobe pdf file types: https://www.adobe.com/devnet-docs/acrobatetk/tools/AdminGuide/pdfviewer.html
There, a machine is configured and then, the file type associations are simply exported using powershell and then this result xml file is deployed using GPOs. Please note that you can edit the result file so that only the file types that IE needs are enforced´to be run with IE11.
0
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

Author Comment

by:ranski
ID: 41883508
Thanks. Yea I've used the default file association but it overwrites the users preference every time they log on.

If I use the above as a logon script do you still expect to see issues?
0
 
LVL 54

Expert Comment

by:McKnife
ID: 41883513
It overwrites them - so that is not what you intend? You don't intend to enforce IE as default browser? So you want to set it but users may change that?

Then use your script. Simply create a file object as marker that it has run like batch code
md %appdata%\admin\scripthasrun
and then make this the first line:
if exist %appdata%\admin\scripthasrun goto end

Sorry, I can offer no no vbs code for this.
0
 

Author Comment

by:ranski
ID: 41883521
That's correct. By default Windows 10 sets Edge as the browser. This is incompatible with our homepage. Chrome and IE11 work fine.

I need to ensure that IE11 is the default browser but if someone wishes to have chrome as the default we still need to allow this
0
 

Accepted Solution

by:
ranski earned 0 total points
ID: 41883613
I have updated the script slightly but can't get it to create the IESET folder. Can anyone help. Sorry i'm not great at vbs these days

Set oWS = WScript.CreateObject("WScript.Shell")
' Get the %userprofile% in a variable, or else it won't be recognized
userProfile = oWS.ExpandEnvironmentStrings( "%userprofile%" )

Dim objNetwork
Dim userName
Dim FSO
Dim Folder

Set FSO = CreateObject("Scripting.FileSystemObject")

Set objNetwork = CreateObject("WScript.Network")
userName = objNetwork.userName

If (FSO.FolderExists(userProfile + "\AppData\Roaming\IESET")) Then
End If


If NOT (FSO.FolderExists(userProfile + "\AppData\Roaming\IESET")) Then
    ' Delete this if you don't want the MsgBox to show
   ' MsgBox("Local folder doesn't exists, creating...")
    splitString = Split(userProfile, "\")

    ' Create folder
   ' MsgBox("C:\" + splitString(2) + "\AppData\Roaming\IESET")
    'FSO.CreateFolder(splitString(2) + "\AppData\Roaming\IESET")
	
	Set WshShell = WScript.CreateObject("WScript.Shell")

    ' force IE Default browser in Windows 10
    WshShell.Run "%windir%\system32\control.exe /name Microsoft.DefaultPrograms /page pageDefaultProgram\pageAdvancedSettings?pszAppName=Internet%20Explorer"

' Allow time for the Default Programs to load before sending next line of actions
    WScript.Sleep 1200

' WshShell.AppActivate "Set Program Associations"
    WshShell.SendKeys "{TAB}"
    WshShell.SendKeys " "
    WshShell.SendKeys "{TAB}"
    WshShell.SendKeys "{TAB}"
'WScript.Sleep 500
    WshShell.SendKeys " "

    'Msgbox "Default browser is now Internet Explorer."

    WScript.Quit
	
	
	End If

Open in new window

0
 
LVL 5

Expert Comment

by:Austin Texas
ID: 41884452
Probably because I am really old, I would typically do this in a batch file using 'IF EXIST c:\flag.txt'
Something like this:
if exist c:\flag.txt (
    rem file exists
) else (
    rem file doesn't exist so set the flag and run VBS
    echo Script run. > c:\flag.txt
    cscript IE10set.vbs
)

Open in new window

0
 

Author Closing Comment

by:ranski
ID: 41889431
Managed to fix it myself. Thanks all
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
How to record audio from input sources to your PC – connected devices, connected preamp to record vinyl discs, streaming media, that play through your audio card: Vista, Windows 7, Windows 8, Windows 8.1 and Windows 10 – both 32 bit & 64.
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question