Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


VBS and Registry keys

Posted on 2004-10-29
Medium Priority
Last Modified: 2012-08-13
Hello everyone,

I have a small issue that I need a little help with. I have a logon script that I use on the network, I have added the ability to delete certain registry keys to it...but it deletes it based on the value (i.e. name). What I want to do is delete it based on the data, for instance we have a user with a virus that makes a key in the key HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce with a value of "wlan driver" and data being serviced.exe. I can delete it based on "wlan driver" but I need to get rid of it based on "serviced.exe"

Any help would be very helpful

Question by:JoeDW
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

sj_hicks earned 1000 total points
ID: 12450640
Following untested code should do it:

set sh = WScript.CreateObject("WScript.Shell")
If ucase(sh.RegWrite("HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce\wlan driver")) = "SERVICED.EXE" then
     sh.RegDelete "HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce\wlan driver"
end if


Author Comment

ID: 12462884
That looks great but would there be anyway to incorporate this into my current code:

Private Sub RegClean

  On Error Resume Next

  Dim strRegKey              
  Dim strSubKey        
  Dim strKey              
  Dim strRegVal        
  strRegKey1 = "HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion"
  strRegKey2 = "HKCU\Software\Microsoft\Windows\CurrentVersion"
  strRegKey3 = "HKLM\Software\Microsoft\Windows\CurrentVersion"
  strSubKey1 = "Run"
  strSubKey2 = "RunOnce"
  strSubKey3 = "RunServices"
  strRegVal1 = "wlan driver"
  strRegVal2 = "MSMGR"
  strRegVal3 = "Windows network driver"
  strKey1 = (strRegKey3 & "\" & strSubKey2 & "\" & strRegVal1)
  strKey2 = (strRegKey3 & "\" & strSubKey2 & "\" & strRegVal2)
  strKey3 = (strRegKey3 & "\" & strSubKey2 & "\" & strRegVal3)
  objWshShell.RegDelete (strKey1)
  objWshShell.RegDelete (strKey2)
  objWshShell.RegDelete (strKey3)
End Sub

Thanks again for the comment

Author Comment

ID: 12465616
never mind I have it now...thanks for the help though

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question