• 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

    • At least on Mint... Debian is the 'backup' option (i.e. LMDE6) where as regular Mint is Ubuntu. also, Debian tends to play stuff a bit more conservatively than Ubuntu (at least based on Mint) with kernel and programs. also, even Mint's 'Update Manager' is more refined in regular Mint vs LMDE6 and installing NVIDIA driver is easier on regular Mint etc. not only that but LMDE6 only comes with Cinnamon which is a shame as they should offer the option for Xfce. I realize playing around with it in a VM one can install Xfce on it but it would be nice to have a more official Xfce release like how the regular Mint does. so while I heard Debian is a little snappier than Ubuntu (so better on some level), Ubuntu is probably the overall wiser choice unless people don't mind using a bit older stuff etc. but honestly, with some tweaks I would not mind if they changed the main Mint to Debian base instead of Ubuntu. but that's probably not likely to happen unless Ubuntu really does something the Mint team does not like. p.s. but I was building Super Mario 64 (native PC port on Linux) a while ago and it does not like regular Mint but works fine on LMDE6. but at that point I just transferred the final binary out of the VM back to my regular Mint and it works fine.
    • Excel is getting a highly requested PivotTable feature by Usama Jawad Microsoft Excel is one of the most popular software out there, both in the enterprise and personal space. It has a variety of use-cases including data analysis, data crunching, visualizations, and even planning and organization assistance. Microsoft regularly updates Excel with new features, and now, it is introducing a notable feature for PivotTables. Prior to today, PivotTables required a manual refresh from the user whenever new data was inserted into them. This wasn't a particularly complicated process, but it was tedious, so based on significant user feedback, Microsoft has decided to implement auto-refresh capabilities in PivotTables. The good thing is that Auto Refresh is enabled for all new PivotTables by default, but you can choose to disable it by selecting a PivotTable, navigating to the PivotTable Analyze tab, and then clicking on Auto Refresh. It is important to note that Auto Refresh is applicable on a per data source level, which means that the feature's state (on or off) will apply to all PivotTables derived from that source. Additionally, if Auto Refresh is disabled or a PivotTable is unable to synchronize, a message at the bottom of your workbook will say "PivotTable Refresh Needed". Once you click on it, all outdated PivotTables will refresh. Finally, you should keep in mind that external and asynchronous data sources do not support Auto Refresh and that the feature may become unavailable when a co-author is using an older version of Excel or if you are playing around with volatile functions like RAND() and NOW() in your data source. Auto Refresh for PivotTables is available right now in the Beta Channel for Excel for Windows version 2506 (Build 19008.2000) or later, and Excel for Mac version 16.99 (Build 250616106) or later. If you don't see it yet, it's better to wait as new capabilities are often rolled out in a staggered manner.
    • Hell of a legacy, hell of a bad person...
    • Man, what a legend. I know a lot of you don't like social media but the outpouring on the platforms has been really something else.
    • No download links, please.
  • Recent Achievements

    • First Post
      Electronic Person earned a badge
      First Post
    • Week One Done
      CyberCeps666 earned a badge
      Week One Done
    • Very Popular
      d4l3d earned a badge
      Very Popular
    • Dedicated
      Stephen Leibowitz earned a badge
      Dedicated
    • Dedicated
      Snake Doc earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      628
    2. 2
      ATLien_0
      240
    3. 3
      Xenon
      163
    4. 4
      neufuse
      126
    5. 5
      +FloatingFatMan
      124
  • Tell a friend

    Love Neowin? Tell a friend!