Solved

VBS Script IE "Pop-Up Blocker Allow Sites" must be run twice to work

Posted on 2008-10-09
10
1,928 Views
Last Modified: 2013-12-08
I found a script to allow sites in the IE Pop-Up Blocker. The script works, but many times it must be run twice to actually input the sites. Any suggestions greatly appreciated.
Const HKEY_CURRENT_USER = &H80000001
 
strComputer = "."
 
Set objRegistry=GetObject("winmgmts:\\" & _ 
    strComputer & "\root\default:StdRegProv")
 
strKeyPath = "Software\Microsoft\Internet Explorer\New Windows\Allow"
strValueName = "*.ericsson.com"
strValue = Array()
objRegistry.SetBinaryValue HKEY_CURRENT_USER,strKeyPath, _
    strValueName,strValue
 
strComputer = "."
 
Set objRegistry=GetObject("winmgmts:\\" & _ 
    strComputer & "\root\default:StdRegProv")
 
strKeyPath = "Software\Microsoft\Internet Explorer\New Windows\Allow"
strValueName = "*.ericsson.net"
strValue = Array()
objRegistry.SetBinaryValue HKEY_CURRENT_USER,strKeyPath, _
    strValueName,strValue
 
strComputer = "."
 
Set objRegistry=GetObject("winmgmts:\\" & _ 
    strComputer & "\root\default:StdRegProv")
 
strKeyPath = "Software\Microsoft\Internet Explorer\New Windows\Allow"
strValueName = "*.redback.com"
strValue = Array()
objRegistry.SetBinaryValue HKEY_CURRENT_USER,strKeyPath, _
    strValueName,strValue

Open in new window

0
Comment
Question by:Led_Zappa
  • 5
  • 5
10 Comments
 

Author Comment

by:Led_Zappa
ID: 22680834
FWIW: I have tried this on multiple Vista Systems with same results.

Here is where I got the instructions for the code. As a beginner, maybe I missed something.

http://www.microsoft.com/technet/scriptcenter/resources/tales/sg0605.mspx
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 22682260
Hi, I'm not sure why you'd have to run it multiple times....but I can shorten the code for you.....

Try this out....

Regards.

Rob.
Const HKEY_CURRENT_USER = &H80000001
 
strComputer = "."
 
Set objRegistry=GetObject("winmgmts:\\" & _ 
    strComputer & "\root\default:StdRegProv")
 
strKeyPath = "Software\Microsoft\Internet Explorer\New Windows\Allow"
strValue = Array()
 
arrValueNames = Array("*.ericsson.com", "*.ericsson.net", "*.redback.com")
 
For Each strValueName In arrValueNames
	objRegistry.SetBinaryValue HKEY_CURRENT_USER,strKeyPath, strValueName,strValue
Next

Open in new window

0
 

Author Comment

by:Led_Zappa
ID: 22682529
So I have noticed something that may help troubleshoot. On a new system I must run the script once and wait a couple seconds and run again. If there is an exception already there, the script works every time. If I chose "remove all" and run the script again it must be run twice. If I remove one exception and run the script the script runs fine every time.

Thanks Rob for shortening the script. I will definitely use it and compare the differences for my own education, unfortunately it did not fix my problem.
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 65

Expert Comment

by:RobSampson
ID: 22683583
Hmmm, maybe we need to make sure the "Allow" key exists before adding the exclusions....

Rob.
Const HKEY_CURRENT_USER = &H80000001
 
strComputer = "."
 
Set objRegistry=GetObject("winmgmts:\\" & _ 
    strComputer & "\root\default:StdRegProv")
 
strKeyPath = "Software\Microsoft\Internet Explorer\New Windows\Allow"
strValue = Array()
 
On Error Resume Next
objRegistry.CreateKey HKEY_CURRENT_USER, KeyPath
Err.Clear
On Error GoTo 0
 
arrValueNames = Array("*.ericsson.com", "*.ericsson.net", "*.redback.com")
 
For Each strValueName In arrValueNames
	objRegistry.SetBinaryValue HKEY_CURRENT_USER,strKeyPath, strValueName,strValue
Next

Open in new window

0
 

Author Comment

by:Led_Zappa
ID: 22689870
Thanks Rob,

Well this definitely deserves more points. I have discovered that the "Allow" key does not exist and is deleted when you select "Remove All" button, but the script you created still does not create the key on the first try. This is a real head scratcher.

Just another note: UAC is disabled so nothing I know of would be preventing this from happening. Especially when the code I have for adding "trusted sites" and setting IE homepage work every thime.

Thanks again for looking into this,

Shawn
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 22691381
OK, please comment the On Error Resume Next on line 11 of my code, and see what error the CreateKey method gives you....

Regards,

Rob.
0
 

Author Comment

by:Led_Zappa
ID: 22691505
Hope I got this right:

Line: 12
Char: 1
Error: Invalid Parameter
Cose: 80041008
Source SWbemObjectEx

- Shawn
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 22693186
Oh whoops!  I just noticed that line has this:
objRegistry.CreateKey HKEY_CURRENT_USER, KeyPath

but the key path you've specified is actually in strKeyPath, so the line should be:
objRegistry.CreateKey HKEY_CURRENT_USER, strKeyPath

Regards,

Rob.
Const HKEY_CURRENT_USER = &H80000001
 
strComputer = "."
 
Set objRegistry=GetObject("winmgmts:\\" & _ 
    strComputer & "\root\default:StdRegProv")
 
strKeyPath = "Software\Microsoft\Internet Explorer\New Windows\Allow"
strValue = Array()
 
On Error Resume Next
objRegistry.CreateKey HKEY_CURRENT_USER, strKeyPath
Err.Clear
On Error GoTo 0
 
arrValueNames = Array("*.ericsson.com", "*.ericsson.net", "*.redback.com")
 
For Each strValueName In arrValueNames
	objRegistry.SetBinaryValue HKEY_CURRENT_USER,strKeyPath, strValueName,strValue
Next

Open in new window

0
 

Author Closing Comment

by:Led_Zappa
ID: 31504731
That was it!

You stayed with it and I appreciate it!

Thanks Rob!

- Shawn
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 22699165
No problem.  Thanks for the grade.

Regards,

Rob.
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBS Script not working correctly. 1 40
Video won't play 5 62
Macro Excel - Multiple If conditions 2 72
Server 2012 management. 5 23
#Citrix #Internet Explorer #Enterprise Mode #IE 11 #IE 8
I'm a big fan of Windows' offline folder caching and have used it on my laptops for over a decade.  One thing I don't like about it, however, is how difficult Microsoft has made it for the cache to be moved out of the Windows folder.  Here's how to …
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

776 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