Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Script for Deleting files/reg keys

  • Please log in to reply
2 replies to this topic

#1 Guest_Illegal Alien_*

Guest_Illegal Alien_*

  • Guests

Posted 10 October 2008 - 07:43 PM

I want to make a script that will delete Registry Keys using wildcards, such as HKEY_CURRENT_USER\test00*. It also has to be able to delete specific files using environment variables such as %appdata% or %homedrive%.

what scripting language would be best to use? Autohotkey(AutoIt), VBS, batch? Any help please. Also, a good source of info for the selected language would be nice too.

BC AdBot (Login to Remove)


#2 groovicus


  • Security Colleague
  • 9,963 posts
  • Gender:Male
  • Location:Centerville, SD

Posted 10 October 2008 - 07:53 PM

What do you mean by best? There are any number of scripting languages that would work equally well.

#3 PlyPencil


  • Members
  • 51 posts
  • Local time:06:01 PM

Posted 11 October 2008 - 02:50 AM

Visual Basic is an EASY language which is easy to pick up and is extremely simple to delete a registry key.

Get Value
Sub Main()

		If My.Computer.Registry.GetValue("HKEY_CURRENT_USER\software\microsoft\windows\currentversion\policies\system\", _
		"TestValue", Nothing) Is Nothing Then
			MsgBox("Value does not exist.")
		End If


End Sub

(keyName as string, Value Name, DefaultValue) is string

Environment Variables

Delete Value
Sub Main()

		My.Computer.Registry.LocalMachine.DeleteValue(name as string)
		My.Computer.Registry.LocalMachine.DeleteSubKey(subkey as string)
		My.Computer.Registry.LocalMachine.DeleteSubKeyTree(subkey as string)


End Sub

Hope this helps,


Edited by PlyPencil, 11 October 2008 - 02:58 AM.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users