• 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

    • Samsung Galaxy Watch8 is now selling at its lowest price ever by Fiza Ali Amazon is now offering Samsung Galaxy Watch8 at its lowest price yet with a 34% discount (purchase link down below). The Galaxy Watch8 is equipped with a 1.5-inch Super AMOLED display with a resolution of 480x480 pixels and support for 16 million colours. The watch is powered by a penta-core processor with clock speeds of up to 1.6GHz, runs Wear OS, and includes 2GB of RAM and 32GB of internal storage. For connectivity, the watch supports Bluetooth 5.3, Wi-Fi 802.11a/b/g/n on both 2.4GHz and 5GHz bands, and NFC. Furthermore, supported Bluetooth profiles include A2DP, AVRCP, HFP, and HSP. Location services are provided through GPS, GLONASS, BeiDou, and Galileo satellite systems. Moreover, the Galaxy Watch8 includes a range of sensors as well, including an accelerometer, barometer, bioelectrical impedance analysis (BIA) sensor, electrical heart sensor (ECG), optical heart rate sensor, gyroscope, geomagnetic sensor, infrared temperature sensor, and ambient light sensor. For media playback, the watch supports MP3, M4A, 3GA, AAC, OGG, OGA, WAV, AMR, and AWB audio formats. In terms of water resistance, it has a 5 ATM rating, which should make it suitable for swimming and everyday exposure to water. Finally, the device is powered by a 435mAh lithium-ion battery, and when it comes to its performance, Samsung rates the battery for up to 40 hours of use with the Always-On Display turned off. Samsung Galaxy Watch 8 (2025) 44mm Smartwatch: $249.99 (Amazon US) - 34% off 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.
  • Recent Achievements

    • Week One Done
      Huge Trailer earned a badge
      Week One Done
    • Week One Done
      Classifyskilleducation earned a badge
      Week One Done
    • One Month Later
      eurospharma62 earned a badge
      One Month Later
    • Week One Done
      With What earned a badge
      Week One Done
    • Week One Done
      Harris Gilbert earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      593
    2. 2
      +Edouard
      170
    3. 3
      PsYcHoKiLLa
      74
    4. 4
      Michael Scrip
      66
    5. 5
      ATLien_0
      64
  • Tell a friend

    Love Neowin? Tell a friend!