Tip: Удаляем программы через vbScript
|
|
|
Воскресенье, 09 Апрель 2006 | (6390)
Бывает так, что Администратору надо удалить ту или иную программы с клиентских компьютеров. Когда речь идёт о небольшём количестве компьютеров, то это не проблема, а вот если сеть (network) большая, то тут может быть трудно. На сегоднишний день есть не мало инструментов, которые могут помочь администратору в данной задаче. Вот один из способов - это можно делать с помощью vbScript.
В данном примере показанно как удалить с компьютера Easy CD Creator. Я думаю, у вас не составит труда "затачить" этот vbScript под ваши нужды.
Содержимое скрипта:
'****************************
'* removeEZCD Subroutine **
'****************************
Sub removeEZCD
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This sub is a temporary sub to remove ezcd creator
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim oWMIService, oShell, oExplorer, colSoftware
' Create a shell object
Set oShell = CreateObject("WScript.Shell")
' Connect to the WMI provider
Set oWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
' Create an instance of internet Explorer and set up it's properties.
Set oExplorer = WScript.CreateObject("InternetExplorer.Application")
oExplorer.Navigate "about:blank"
' do we want a toolbar? 1=yes 0=no
oExplorer.ToolBar = 0
' do we want a statusbar? 1=yes 0=no
oExplorer.StatusBar = 0
oExplorer.Width=400
oExplorer.Height = 200
oExplorer.Left = 0
oExplorer.Top = 0
' wait for Internet Explorer to load up before updating inner html
Do While (oExplorer.Busy)
WScript.Sleep 200
Loop
' Make this instance of internet explorer visible and update
' the internal html
oExplorer.Visible = 1
oExplorer.Document.Body.InnerHTML = "Checking for Easy CD Creator installation"
' create a query for ezcd creator
Set colSoftware = oWMIService.ExecQuery _
("Select * from Win32_Product Where Name = 'Easy CD Creator 5 Basic'")
' check to see if there are any returns on the query
If colSoftware.count = 0 Then
' if not update inner html and then exit
oExplorer.Document.Body.InnerHTML = "No Easy CD Creator Installation was found. Exiting..."
Else
' if the app is found, update inner html
For Each oSoftware in colSoftware
oExplorer.Document.Body.InnerHTML = "Removing " & oSoftware.name
Do While (oExplorer.Busy)
WScript.Sleep 200
Loop
oExplorer.Document.Body.InnerHTML = "Please continue to wait..."
On Error Resume Next
' uninstall ezcd creator
oSoftware.Uninstall()
' error checking
If Err.Number <> 0 Then
' if there is an error give a description of the error
oExplorer.Document.Body.InnerHTML = "There was an error uninstalling " & oSoftware.name
oExplorer.Document.Body.InnerHTML = "Description: " & Err.Description
Else
' if it was uninstalled successfully let the user know
oExplorer.Document.Body.InnerHTML = oSoftware.name & " has been successfully uninstalled."
End If
Next
End If
' allow processes to finish, close IE
WScript.Sleep 3000
oExplorer.Quit
End Sub
|
Вы можете скчать этот скрипт в текстовом формате, только не забудьте переименовать файл, что бы у него было расширение VBS.
Скачать
|