Solved

Set IE11 as default in Windows 10 (once)

Posted on 2016-11-10
9
26 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 53

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
 

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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 53

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Roguekiller has no option of deleting 19 46
Powershell 16 31
Windows 10 hide system tray icons 1 26
Windows 10 will not update 7 30
Windows 10 introduced a new kind of product activation called Digital Entitlement, in addition to using the conventional product key activation. In this article I investigated the detail of such activation and provide some tips so you can understand…
My experience with Windows 10 over a one year period and suggestions for smooth operation
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

758 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now