Jump to content

Recommended Posts


Posted

Yes you can use a VBS script to do that.

This VBS script writes to the registry then checks for the value then deletes the value.

I have set it so it has message boxes popup at each stage.

Save As Test_Write_Check_Delete.vbs

Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
strValueTest = "Test Value" : strValueName = "Test Value"
Dim Act : Set Act = CreateObject("Wscript.Shell")
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
objRegistry.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValueTest '''' VALUE THAT GET WRITTEN TO THE REG
MsgBox "The Test Write To The Registry Was Written" & vbCrLf & "Press Key To Continue", 0 + 48, "Test Reg Write"
objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue '''' VALUE THAT IT CHECKS FOR
If IsNull(strValue) Then '''' CHECK FOR THE REG VALUE
MsgBox "The Test Failed And Nothing Was Written", 0 + 48, "Test Failed" '''' VALUE IS NOT THERE
Else '''' THE VALUE IS THERE
ZZ1 = MsgBox ("Confirm Test Write Worked" & vbCrLf & "Did You Want To Open The Registry?" & vbCrLf &_
"To Check Before It Deleted" & vbCrLf & "Press Yes To Open Reg Edit" & vbCrLf &_
"Press No To Just Delete The Value" , 4 + 32, "Confirm Or Delete Value")
If ZZ1 = 6 Then '''' YES CHECK THE REG FOR THE VALUE USING REGEDIT.EXE
MsgBox "Open This Key In Reg Edit To Check Before Delete" & vbCrLf &_
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\" & strValue, 0 + 32, "Reg Value"
Act.Run("Regedit.exe"),1,True : MsgBox "Press Key To Continue", 0 + 32, "Delete Value"
objRegistry.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue '''' DELETE THE REG VALUE
End If
'''' NO JUST DELETE THE VALUE WITHOUT OPENING REGEDIT.EXE
If ZZ1 = 7 Then : objRegistry.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue : End If
End If
Act.Run("Regedit.exe") ''' REOPEN REG EDIT AND SEE THE KEY IS GONE

Here are some link that will help you Work The Registry using VBS script

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...