Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2008-10-09
10
Medium Priority
?
2,075 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
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.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

721 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