• 0

Find and delete registry keys/values


Question

Hi. I'm not too brilliant with VBScript, so please bear with me. I'm trying to create a script to search for xyz value in the registry and delete it from a target machine.

I'd like the process to be:

Box to input xyz

Box to input target machine name

Scan target registry and delete the value, keep scanning until all are deleted.

Report how many deleted or report if none found.

Is this possible?

So far I have:

Set WshShell = WScript.CreateObject("WScript.Shell")
Set DelReg = GetObject ("WinMgmts:{impersonationLevel=impersonate}!//./root/default:StdRegProv")

'Constants for WMI StdRegProv
Const HKCU = &H80000001
Const HKLM = &H80000002
Const HK_USERS = &H80000003

'On Error Resume Next

sStartKeyPath = "" 'Sets the search to start from the root of the registry

Do while regkey = ""
regkey = InputBox("What would you like to search the registry for?")
if regkey = "" then
msgbox "Please enter search criteria."
End if
Loop

DelReg.DeleteValue regkey[/CODE]

At the moment I can't even get it to search and delete a key from my own machine.

Link to comment
https://www.neowin.net/forum/topic/1150082-find-and-delete-registry-keysvalues/
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Here is a VBS script that I wrote to help you handle getting the Registry Key and Computer Name.

The X and Cancel will not close the Inputbox. The only way to cancel is to type in Exit or Quit.

'-> Variables For Run Time
Dim Input, R1, R2, Tx
Tx = "Type either Exit or Quit to cancel and do nothing"

'-> Get The Key Name
  UserIn("Type in the Registry Key that you want to search for?" & _
         vbCrLf & Tx)
  R1 = Input

'-> Get The Computer Name
  UserIn("Type in the Computer Name for this script?" & _
         vbCrLf & Tx)         
  R2 = Input

'-> Inputboxes Return
   MsgBox "Registry : " & R1 & vbCrLf & _
          "Computer : " & R2, 4128,"Demo Return"

'-> Get User Input
  Function UserIn(Msg)    
   Input = Inputbox(Msg,"","",5500,5500)   
    If LCase(InStr(1,Input,"exit",1)) Or _
       LCase(InStr(1,Input,"quit",1)) Then
     WScript.Quit(0) 
    End If 
    If Input <> "" And Len(Input) > 3 Then Exit Function
   UserIn(Msg) 
  End Function

This topic is now closed to further replies.
  • Posts

    • Amazon takes hundreds of dollars off its Kindle readers ahead Prime Day by Taras Buria Ahead of its Prime Day, Amazon brought its Kindle readers to all-time low prices, allowing you to save on various bundles across the entire lineup, from the most affordable Kindle to the flagship Scribe and its color-enabled variant. Kindle Essentials Bundle - $108.97 | 33% off This 6-inch Kindle is a portable reader with a front light, a brighter E-Ink display, and up to 6 weeks on a single charge. The bundle includes a protective case and a charger, so that you have everything you need for comfortable reading. Kindle Paperwhite Bundle - $154.98 | 45% off Kindle Colorsoft Bundle - $169.98 | 48% off The latest Paperwite is a 7-inch reader that features significantly faster page-turning, wireless charging, an ambient light sensor, 32GB of storage, and up to 12 weeks on a single charge. Right now, the bundle with a sling bag makes the Paperwhite 25% cheaper than the non-bundle variant. The same bundle is available for the Colorsoft version with a colorful E-Ink display. Kindle Scribe 32GB Bundle - $444.97 | 27% off Kindle Scribe Colorsoft 64GB Bundle - $574.97 | 27% off The Scribe is the biggest, flagship Kindle. It has an 11-inch texturized display with a stylus support, with a big emphasis on the note-taking experience. The built-in notebook has AI-assisted features for search, refinements, summarization, and more. The Scribe comes with 32GB of storage, and the bundle gets you a case, a stylus, and a protective case. Like with the Paperwhite, there is a Colorsoft version, which is also available with a massive discount. Note: These deals are available to Prime members only. If you do not have Prime, you can sign up using one of the links below. Good to know This Amazon deal is U.S. specific, and not available in other regions unless specified. We only use first-party seller links (at the time of article publishing); ensure that you purchase from a first-party seller link only. Check out Today's Deals on Amazon | or our recent tech deals. Become a Prime member (for Students or SNAP) via Neowin Get Prime Access - Prime for half price (for qualifying Medicaid, EBT, SNAP) Subscribe to Prime Video, Audible Plus, Music Unlimited or Kindle Unlimited via Neowin As an Amazon Associate, we earn from qualifying purchases.
    • nice rack! lol
    • yep and it's doing better than my razer basilisk v2 did. that mouse had scroll issues and I even took it apart and cleaned it and scroll still janky. Thank you ^_^
    • I tried to get the latest secureboot certificate for my old Dell 7010 Optiplex machine.   I restored the default settings to Secure Boot. Big mistake.  Now when secure boot is on. The machine doesn't boot and complains about no booting devises.  The computer's secure boot can't find where to boot and the information apparently has to be entered manually.  Secureboot's settings are now years old and it can't find a new configuration.  What could be done here? There are plenty of files to choose from in the secureboot menu, but I don't know what to put there for each of the four Windows 11 upgraded from 10..... originally who knows what (used machine) without secureboot it booting normally  
    • I see you're still rocking that g700 mouse
  • Recent Achievements

    • Dedicated
      Almohandis earned a badge
      Dedicated
    • Dedicated
      JuvenileDelinquent earned a badge
      Dedicated
    • First Post
      DrWankel earned a badge
      First Post
    • Reacting Well
      DrWankel earned a badge
      Reacting Well
    • Week One Done
      Supreme Spray LV earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      504
    2. 2
      +Edouard
      174
    3. 3
      PsYcHoKiLLa
      84
    4. 4
      Steven P.
      76
    5. 5
      Michael Scrip
      76
  • Tell a friend

    Love Neowin? Tell a friend!