Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Registry deletion

Status
Not open for further replies.

nikhil2010

Programmer
Nov 11, 2010
9
IN
Hi I want to write vbscript code
req is like I want to delete the whole branch say

I have a subkey called "A" Under that whatever comes it should be deleted. But I think vb doesnt allow to do unless we delete everything under that.

How do I do that??
 
PHV sorry I'm new to that I learnt Wshell to perform normal deletion but the help content you gave seems to be completely different!!
 
p.s. i am guessing you will get a run time if you try and delete a registry key which has subkeys using WshShell.RegDelete, and hence PHV's post

I Hear, I Forget
I See, I Remember
I Do, I Understand

Ronald McDonald
 
Yeah it doesnt allow to delete whole branch unless I delete entries below that. I tried Is any other technique something where I can delete whole branch??
 
PHV thanks for the link I got the class articles, but one doubt

what is meaning of this code

Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_
strComputer & "\root\default:StdRegProv")
I know its creating WMI object and getting a reference but no explanation is given is much for this.. Can you help?
 
this is an equivelance of you doing (sort of)

Set WshShell = CreateObject("Wscript.Shell")

By doing the Set objReg = GetObject("winmgmts...etc you are connecting to the WMI of the strComputer and specifically connecting to the StdRegProv (standard registry provider) provider, this will then give you access to that providers Methods and Properties, e.g. RegDelete EnumKeys etc


I Hear, I Forget
I See, I Remember
I Do, I Understand

Ronald McDonald
 
Thanks mrmovie that syntax was bothering me and where I can I find more explanation on that?
 
tsuji its complex but thanks now How do I understand or rather what should I read first before going thru winmgts ...... Im quite new to this..
 
taken from an activeexperts example on scripting the registry:

Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\System Admin Scripting Guide"
oReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath

I Hear, I Forget
I See, I Remember
I Do, I Understand

Ronald McDonald
 
i dont know if regedit.exe using the - to delete a registry key will delete the subkeys as well, i know it strictly not vbscript but it might be what you are after

I Hear, I Forget
I See, I Remember
I Do, I Understand

Ronald McDonald
 
for a less robust, "git'r done" approach, review the dos cmdline "reg"

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top