以VBScript撰寫自動移除ask toolbar,程式如下:

 

Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
oReg.EnumKey HKLM, strKeyPath, arrSubKeys

For Each subkey In arrSubKeys

    displayname=""
    DisplayVersion = ""
    InstallDate = ""
    UninstallString = ""
            
    If left(subkey,2)<>"KB" Then
       strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" & "\" & subkey
       strValueName = "DisplayName"
       oReg.GetStringValue HKLM,strKeyPath,strValueName,strValue
       DisplayName = strValue        
       If ("" & strValue) <> "" And strValue="Ask Toolbar" Then  
           strValueName = "UninstallString"
           oReg.GetStringValue HKLM,strKeyPath,strValueName,strValue
           UninstallString = strValue
    
           strValueName = "SystemComponent"
           oReg.GetDWORDValue HKLM,strKeyPath,strValueName,strValue
           SystemComponent = strValue
           If isnull(strValue) Or strValue=0 Then
              Set objShell = Wscript.CreateObject("Wscript.Shell")
              objShell.Run "cmd /c" & Replace(UninstallString,"/I","/qn /X")
              Set oShell = Nothing
           End If              
       End If                                
    End If
 
Next

Set objWMIService1 = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems1 = objWMIService1.ExecQuery("SELECT * FROM Win32_Processor")
For Each objItem1 in colItems1
    If objItem1.AddressWidth="64" then 'CPU 64位元電腦
       Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
 
       strKeyPath = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
       oReg.EnumKey HKLM, strKeyPath, arrSubKeys

        FOR EACH subkey IN arrSubKeys
            displayname=""
            DisplayVersion = ""
            InstallDate = ""
            UninstallString = ""

            strKeyPath = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" & "\" & subkey
            strValueName = "DisplayName"
            oReg.GetStringValue HKLM,strKeyPath,strValueName,strValue
            DisplayName = strValue
            IF ("" & strValue) <> "" And strValue="Ask Toolbar" THEN  
               strValueName = "UninstallString"
               oReg.GetStringValue HKLM,strKeyPath,strValueName,strValue
               UninstallString = strValue
               
               strValueName = "SystemComponent"
               oReg.GetDWORDValue HKLM,strKeyPath,strValueName,strValue
               SystemComponent = strValue               
               IF isnull(strValue) THEN            
                  Set objShell = Wscript.CreateObject("Wscript.Shell")
                  objShell.Run "cmd /c" & Replace(UninstallString,"/I","/qn /X")
                  Set oShell = Nothing
               END IF                     
            END IF
        NEXT            
    END IF
NEXT

 

arrow
arrow

    JojoChen 發表在 痞客邦 留言(0) 人氣()