?
Solved

VBS and Registry keys

Posted on 2004-10-29
3
Medium Priority
?
326 Views
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

Thanks
0
Comment
Question by:JoeDW
  • 2
3 Comments
 
LVL 7

Accepted Solution

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

0
 
LVL 1

Author Comment

by:JoeDW
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
0
 
LVL 1

Author Comment

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

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

589 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