P
Peter Avalos
My goal is to create a remote installation program to rollout program
installs and updates. We're a small company with about 60 workstations, so
it's not worth the investment in SMS. I have the first part working which
used the directory services namespace to enumerate the workstations in a
specific OU. I then populate a listbox with those values. The system admin
(SA) then selects the workstation(s) to install the software package or
select all. The SA then selects the software package through an open
dialog box. After this the SA would just click an "install software" button
and then a loop would run passing in selected workstations from the listbox
to the following sub:
'--------------------------------------------------------------------------------
Private Sub InstallSoftware(ByVal strComputer As String)
Try
Dim options As New ConnectionOptions
Dim objMgtBase As ManagementBaseObject
'Admin user credentials
options.Username = "username"
options.Password = "password"
Dim scope As New ManagementScope("\\" & strComputer & "\root\cimv2",
options)
scope.Connect()
Dim objSoftware As New ManagementObject(scope, New
ManagementPath("Win32_Product"), Nothing)
objMgtBase = objSoftware.GetMethodParameters("Install")
Me.lstProperties.Items.Add("Installed on " & strComputer & " successfully")
Catch Ex As Exception
Me.lstProperties.Items.Add(Ex.Message)
End Try
End Sub
'--------------------------------------------------------------------------------
And exception comes up with regard to the parameter list ("Specified
argument was out of the range of valid values. Parameter name: path") in the
Dim objSoftware As New ManagementObject(scope, New
ManagementPath("Win32_Product"), Nothing) declaration.
In other words how do I "translate" the following VB Script code that works
into VB.NET code that works?
'--------------------------------------------------------------------------------
Const wbemImpersonationLevelDelegate = 4
Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objConnection = objwbemLocator.ConnectServer _
("WebServer", "root\cimv2", "domain\administrator", _
"password", , "kerberos:WebServer")
objConnection.Security_.ImpersonationLevel = wbemImpersonationLevelDelegate
Set objSoftware = objConnection.Get("Win32_Product")
errReturn = objSoftware.Install("\\fileserver01\scripts\1561_lab.msi",,True)
'--------------------------------------------------------------------------------
Secondly, what's the most efficient way to check if a workstation has the
WMI service running? I have an Exception block that will handle the "RPC
Server is unavailable" exception, but it drastically slows down the
application.
Lastly, is there another way to rollout software using the .NET framework
that doesn't use the WMI API? Is there an "easier" way?
Thanks in advance,
~Peter
installs and updates. We're a small company with about 60 workstations, so
it's not worth the investment in SMS. I have the first part working which
used the directory services namespace to enumerate the workstations in a
specific OU. I then populate a listbox with those values. The system admin
(SA) then selects the workstation(s) to install the software package or
select all. The SA then selects the software package through an open
dialog box. After this the SA would just click an "install software" button
and then a loop would run passing in selected workstations from the listbox
to the following sub:
'--------------------------------------------------------------------------------
Private Sub InstallSoftware(ByVal strComputer As String)
Try
Dim options As New ConnectionOptions
Dim objMgtBase As ManagementBaseObject
'Admin user credentials
options.Username = "username"
options.Password = "password"
Dim scope As New ManagementScope("\\" & strComputer & "\root\cimv2",
options)
scope.Connect()
Dim objSoftware As New ManagementObject(scope, New
ManagementPath("Win32_Product"), Nothing)
objMgtBase = objSoftware.GetMethodParameters("Install")
Me.lstProperties.Items.Add("Installed on " & strComputer & " successfully")
Catch Ex As Exception
Me.lstProperties.Items.Add(Ex.Message)
End Try
End Sub
'--------------------------------------------------------------------------------
And exception comes up with regard to the parameter list ("Specified
argument was out of the range of valid values. Parameter name: path") in the
Dim objSoftware As New ManagementObject(scope, New
ManagementPath("Win32_Product"), Nothing) declaration.
In other words how do I "translate" the following VB Script code that works
into VB.NET code that works?
'--------------------------------------------------------------------------------
Const wbemImpersonationLevelDelegate = 4
Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objConnection = objwbemLocator.ConnectServer _
("WebServer", "root\cimv2", "domain\administrator", _
"password", , "kerberos:WebServer")
objConnection.Security_.ImpersonationLevel = wbemImpersonationLevelDelegate
Set objSoftware = objConnection.Get("Win32_Product")
errReturn = objSoftware.Install("\\fileserver01\scripts\1561_lab.msi",,True)
'--------------------------------------------------------------------------------
Secondly, what's the most efficient way to check if a workstation has the
WMI service running? I have an Exception block that will handle the "RPC
Server is unavailable" exception, but it drastically slows down the
application.
Lastly, is there another way to rollout software using the .NET framework
that doesn't use the WMI API? Is there an "easier" way?
Thanks in advance,
~Peter