VBS and Registry keys

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

Thanks
LVL 1
JoeDWAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sj_hicksCommented:
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

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JoeDWAuthor Commented:
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
0
JoeDWAuthor Commented:
never mind I have it now...thanks for the help though
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.