Solved

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

Posted on 2008-10-09
10
1,890 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
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
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
That was it!

You stayed with it and I appreciate it!

Thanks Rob!

- Shawn
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
No problem.  Thanks for the grade.

Regards,

Rob.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
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.
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

771 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