[path] RegDelete [Key] | [Value]
Path Path to RegDelete (so Windows can find it). See the tip on the Windows 98 Tips and Hacks page to make Windows always find it.
Nothing Starts RegDelete with a User Interface. Do not enclose keys or values in inverted commas when typing the key or value to delete.
Key The key to delete. Keys always end in a backslash. If the key contains a space it must be enclosed in inverted commas. Keys and sub-keys will be deleted.
Value The value to delete. Values do not have a trailing backslash. If the key contains a space it must be enclosed in inverted commas.
Copy the following lines into a new text document and save as RegDelete.vbs.
'RegDelete.vbs
'Deletes keys or values from the registry.
'
'
On Error Resume Next
vbPara=vbCRLF & vbCRLF
strExplain="RegDelete deletes keys and values from the registry." & vbPara & "Keys must end with a backspace and values must not." & vbPara & "Start without parameters to type in a key or value to delete, or place the key or value on the command line (use inverted commas to surround the key or value if it contains spaces)." & vbPara & "Continue"
strTitle="Reg Delete"
Key=""
Dim silent
Silent=""
Dim Sh
Set Sh = WScript.CreateObject("WScript.Shell")
ReportErrors "Creating Shell"
Key=GetKey()
If Key<>"" then
B=Sh.RegRead (Key)
If Err.Number=0 Then
Sh.RegDelete Key
If Err.Number =0 Then
If silent<>"yes" Then MsgBox Key & " deleted", vbOKOnly + vbInformation, strTitle
Else
ReportErrors "DeletingKey"
End If
Else
If Err.Number=-2147024893 then
Err.Clear
MsgBox Key & " didn't exist", vbOKOnly + vbCritical, strTitle
Else
ReportErrors "Reading before Deleting Key"
End If
End If
End If
ReportErrors "Main"
Function GetKey()
Dim Ag
Set Ag=Wscript.Arguments
ReportErrors "Creating Aguments"
If Ag.Count=1 then GetKey=Ag(0)
Silent="yes"
If Ag.Count >1 then sgBox "Too many parameters on command line. Try enclosing the key in a space",vbOKOnly + vbCritical, strTitle
If Ag.Count=0 then
If MsgBox (strExplain, vbYesNo + vbInformation, strTitle)=6 Then
GetKey=InputBox ("Enter the value or key to delete." & vbPara & "Keys must end in a backspace.", strTitle, strNamet1)
End If
End If
End Function
Sub ReportErrors(strModuleName)
If err.number<>0 then Msgbox "Error occured in " & strModuleName & " module of " & err.number& " - " & err.description & " type" , vbCritical + vbOKOnly, "Something unexpected"
Err.clear
End Sub