Solved

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

Posted on 2008-10-09
10
1,973 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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.
#Citrix #Internet Explorer #Enterprise Mode #IE 11 #IE 8
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…
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 +…

734 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