Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Аватара для Raistlin

Ветеран


Сообщения: 573
Благодарности: 28

Профиль | Отправить PM | Цитировать


Petya V4sechkin, не могу сообразить, как реализовать поиск пакетов на удаленной машине. Изменил код в соответствии с имеющимся в той теме:
Код: Выделить весь код
'Uninstalls a remote MSI package.
'http://vbscriptwmi.uw.hu/ch31lev1sec4.html

'get remote computer name
Dim sMachine
sMachine = InputBox("Computer name?")
'get admin credentials
Dim sAdminUser, sPassword
sAdminUser = InputBox("Enter the admin user name.")
sPassword = InputBox("Enter the users password. ")
'get a WMI Locator
Dim oLocator
Set oLocator = CreateObject("WbemScripting.SWbemLocator")
'connect to remote machine
Dim oService
Set oService = oLocator.ConnectServer(sMachine, "root\cimv2", _
    sAdminUser, sPassword)
'get a list of installed products
Dim sMsg, sName
For Each oProduct in GetObject( _
 "winmgmts:{impersonationLevel=impersonate}!\\" & sMachine & "\root\cimv2" _
 ).InstancesOf("win32_Product")
 'is this the product we want?
 sMsg = "Product: " & vbCrLf
 sMsg = sMsg & oProduct.Name
      sMsg = sMsg & vbCrLf & "Uninstall this product?"
 If MsgBox(sMsg, 4) = 6 Then
  sName = oProduct.Name
  Exit For
 End If
Next
'Get the named package
For each oProduct in GetObject( _
 "winmgmts:{impersonationLevel=impersonate}" _
 ).ExecQuery _
      ("Select * from Win32_Product where Name='" & sName & "'")
 'uninstall it
      oProduct.Uninstall
      'done!
      MsgBox "Uninstalled " & sName
Next
Собственно, изменил всего одну строку:
Код: Выделить весь код
For Each oProduct in GetObject( _
 "winmgmts:{impersonationLevel=impersonate}!\\" & sMachine & "\root\cimv2" _
 ).InstancesOf("win32_Product")
На ней же и спотыкаемся:
Цитата:
Uninstall.vbs(20, 1) Microsoft VBScript runtime error: The remote server machine does not exist
or is unavailable: 'GetObject'
Iska, ваш скрипт работает, но, к сожалению, адаптировать его к "моему" ума не хватает.

-------
Magically yours
Raistlin


Отправлено: 01:01, 29-01-2012 | #4