Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Does anyone know how to delete registry hive through vbscript?
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.RegDelete "HKCU\Myhive\"
I keep getting error indicate unable to remove key.

You don't delete a key. You add a negative key. eg. -HKCU\Myhive\
To delete a value the minus sign comes after the value. eg. HKCU\Myhive\MyValue-
HTH
Bryan

In vbscript, you can't use a negative to registry hive. I have tried and argument is invalid. I am trying to delete a whole registry hive not just one key. I read somewhere where that vbscript is does not support reg delete of hive if the sub keys aren't empty. If this true, does anyone know a whay around. I tried a batch file with the /f but it still prompts when it is executed. I want it to be transparent to user end when it is ran with no user intervention.

How about regedt32.exe /s [-HKCU\Myhive]
I really don't know the answer but trying to lend assistance. I do not know the inner workings of vbscript.
If no go then I will back off,
Bryan

Bryan,
Much appreciation for your assistance. But how can I incorporate that command structure in vbs?
'Delete CCTP registry hive
Set WshShell = CreateObject("WScript.Shell")
WshShell.RegDelete "HKCU\Software\Myhive"Are you talking about running that command through a batch file? If you are then I can accomplish that through a batch, but it still require user intervention for the batch to proceed with the deletion of the hive.

According to the follwoing article it is possible to import the -reg file by running it from a batch file in silent mode:
http://www.winguides.com/article.php?id=1&page=4&guide=registry
HTH
Bryan

![]() |
Copying Files to 5 Drives
|
internet sharing
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |