Script to check apps installed and remove unwanted apps

Discussion in 'Scripting' started by andy_p, Jan 12, 2005.

  1. andy_p

    andy_p Guest

    I am trying to write a script that will remove Spyware applications installed
    on a user's workstation. So I am trying to write something that loops
    through installed applications and removes the ones that come from a list.
    Anyone have an idea on how to do this?
    andy_p, Jan 12, 2005
    1. Advertisements

  2. Hi

    To enumerate the Add/Remove Programs list:

    sComputer = "." ' use . for local computer
    sAppsList = InstalledApplications(sComputer)

    For Each sAppName In Split(sAppsList, vbCrLf)
    If sAppName <> "" Then
    WScript.Echo sAppName
    End If

    Function InstalledApplications(node)
    Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
    Set oRegistry = _
    GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
    & node & "/root/default:StdRegProv")
    sBaseKey = _
    iRC = oRegistry.EnumKey(HKLM, sBaseKey, arSubKeys)
    For Each sKey In arSubKeys
    iRC = oRegistry.GetStringValue( _
    HKLM, sBaseKey & sKey, "DisplayName", sValue)
    If iRC <> 0 Then
    oRegistry.GetStringValue _
    HKLM, sBaseKey & sKey, "QuietDisplayName", sValue
    End If
    If sValue <> "" Then
    InstalledApplications = _
    InstalledApplications & sValue & vbCrLf
    End If
    End Function
    Torgeir Bakken \(MVP\), Jan 12, 2005
    1. Advertisements

  3. Interesting. Do you find that all Spyware and other nuisance "applications"
    actually "install" themselves the way well-behaved applications are supposed
    to do?

    Al Dunbar [MS-MVP], Jan 13, 2005
  4. Hi

    Some few do, but most do not...
    Torgeir Bakken \(MVP\), Jan 13, 2005
  5. andy_p

    andy_p Guest

    Thanks Torgeir Bakken.. this worked

    andy_p, Jan 14, 2005
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.