• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 637
  • Last Modified:

Push deploy msi vb.net


I am struggling to push an MSI to machines on a domain.
I have written a little VB.NET app to list machines in a domain.
I then select a machine from the list, and pass the machine name to the below function.

The code works perfectly when deploying the MSI to the machine I am running exe on, but does not work when I select another machine (another machine on the domain). I suspect this may be a

1) Permissions problem? (I am logged into the machine with admin so not passing anything)
2) The location of the MSI file (I have put it in a SHARE on the network that all machines can see \\Server\...msi)

And yes the firewall is off on the remote machine.

In terms of errors - the code runs all the way through, without any problems, so it looks like it has initiated the MSIExec call successfully on the remote machine?

Any help would be appreciated.



Private Function deployMSI(ByVal MachineName As String) As String


            Dim deployFile As String = txtMSI.Text
            If IO.File.Exists(deployFile) = False Then
                Return "No MSI found"
                Exit Function
            End If

            Dim options As New ConnectionOptions()
            'options.Username = "domain\\username"
            'options.Password = "password"

            Dim path As New ManagementPath("\\" & MachineName & "\root\cimv2:Win32_Process")
            Dim scope As New ManagementScope(path, options)
            scope.Options.Timeout = New TimeSpan(5000) ' 5 secs
                ' Right, connect to the remote machine:
            Catch ex As Exception

                Return "Could not connect to machine..." & ex.Message
                Exit Function

            End Try

            Dim Opt As New ObjectGetOptions()
            Dim ClassInstance As New ManagementClass(scope, path, Opt)
            Dim inParams As ManagementBaseObject = ClassInstance.GetMethodParameters("Create")
            Dim tmpParams As String = ""

            If deployFile.ToString().ToUpper().EndsWith(".MSI") Then
                ' Run MSIExec on the remote computer
                tmpParams = "MSIExec /i " & deployFile & " /qn"
                logIT("Parameters set : " & tmpParams)
                inParams("CommandLine") = (tmpParams)
            End If

                ' Run the Create Process WMI command to invoke either a direct invocation of a exe or a invocation of msiexec...
                Dim outParams As ManagementBaseObject = ClassInstance.InvokeMethod("Create", inParams, Nothing)

            Catch ex As Exception
                Return ex.Message
            End Try

            Return "Successful"

        Catch ex As Exception
            Return ex.Message
        End Try

    End Function

  • 2
1 Solution
Mohamed OsamaSenior IT ConsultantCommented:
can you please take a look at the below accepted solution which utilizes PSexec tool from sysinternals suite to distribute and deploy an MSI to a list of servers.
this approach is way better than coding your own app from scratch IMHO

CraigLazarAuthor Commented:
Hi Admin 3K,
Thanks for your feedback.
I am putting a little managament console together that performs some other functions too, ie not just the push deployment.:(.
CraigLazarAuthor Commented:
Question has a verified solution.

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.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now