Imports System.Management
Public Class Form1
Private Sub subWMInstall()
Dim strComputer As String = "RemoteComputerName"
Dim ConnectionOptions As New System.Management.ConnectionOptions
ConnectionOptions.Username = Trim("DomainAdminUserName") '(strComputer & "\LocalAdminUserName") for local user account
ConnectionOptions.Password = Trim("DomainAdminUserPassword")
Dim ManagementScope As New System.Management.ManagementScope("\\" & strComputer & "\root\cimv2", ConnectionOptions)
Dim ManagementPath As New System.Management.ManagementPath("Win32_Process")
Dim ManagementOptions As New System.Management.ObjectGetOptions
Dim ManagementClass As New System.Management.ManagementClass(ManagementScope, ManagementPath, ManagementOptions)
Dim OutputParameters As System.Management.ManagementBaseObject
Dim InputParameters As System.Management.ManagementBaseObject
Try
ManagementScope.Connect()
InputParameters = ManagementClass.GetMethodParameters("Create")
InputParameters("CommandLine") = "msiexec /package C:\Test_Install.msi"
OutputParameters = ManagementClass.InvokeMethod("Create", InputParameters, Nothing)
Catch ex As Exception
MsgBox("There was an error connecting to the remote computer." & vbNewLine & ex.Message)
End Try
End Sub
End Class
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
From novice to tech pro — start learning today.
Open in new window