?
Solved

VBScript to Rescurse through HKEYUSERS and to remove restricted sites from each SID

Posted on 2008-10-09
2
Medium Priority
?
684 Views
Last Modified: 2012-05-07
Need a VBScript to Rescurse through HKEY_USERS and to remove 1 or more  restricted sites from each SID.

I probably will have to load their hives, delete, then unload hive. But have not done before. Recently took up VBScripting a few months ago.

Thank You for any assistance.

Here is key I need to delete: HKEY_USERS\"WhateverSid"\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\FaceBook.com ,etc.
0
Comment
Question by:Inuyashapl
[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
2 Comments
 
LVL 5

Accepted Solution

by:
si_shamil earned 675 total points
ID: 22683771
Here you go:
Const DOMAIN = "Facebook.com"
 
Const HKEY_USERS = &H80000003
Const ZMAP_REGKEY = "\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\"
 
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
objReg.EnumKey HKEY_USERS, "", arrSubkeys
 
For Each strSubkey in arrSubkeys
    strKeyPath = strSubkey & ZMAP_REGKEY & DOMAIN
    delRegKey HKEY_USERS, strKeyPath
Next
 
Sub delRegKey(pHive, byVal pKey)
	Dim objReg, strSubkey, arrSubkeys, strKey, arrSplit, intReturn
	Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
	
    ' Remove ending backslash (\) if exists
	If Right(pKey, 1) = "\" Then
		pKey = Left(pKey, Len(pkey) - 1)
	End If
    
	intReturn = objReg.EnumKey(pHive, pKey, arrSubkeys)
	If intReturn <> 0 Then Exit Sub 
 
    If isArray(arrSubkeys) Then	
        For Each strSubkey in arrSubkeys
            delRegKey pHive, pKey & "\" & strSubkey
        Next
    End If
 
    Wscript.Echo "Deleting key: " & pKey
    objReg.DeleteKey pHive, pKey
End Sub

Open in new window

0
 

Author Closing Comment

by:Inuyashapl
ID: 31618363
Modified it to open the ntuser.dat file, make change and unload hive. Thank you.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
When you upgrade from Windows 8 to 8.1 or to Windows 10 or if you are like me you are on the Insider Program you may find yourself with many 450MB recovery partitions.  With a traditional disk that may not be a problem but with relatively smaller SS…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
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…

777 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