I want to run an msi installation file on remote servers from a vb.net application on my machine. I can directly access these machines using the path: \\servername\ and I have administrative rights. Attached is the code I'm trying to use. First, I copy the msi unto the remote server which works but the code to execute the msi doesn't work. I'm using the process.start() method to start the windows msiexec program but it doesn't seem to work. What am I doing wrong?
Also, how can I check if the installation was successfull via my vb.net application and write to a log file.
Private Sub Myfunc()
Dim fi As System.IO.FileInfo = Nothing
Dim fileWithServerNames As String = System.Environment.CurrentDirectory & "\ListOfServers.txt"
Dim sr As StreamReader = New StreamReader(fileWithServerNames)
Dim tempServerPath As String = ""
Dim myMSIFilePath As String = ""
Dim myMSIFileName As String = ""
'Get the msi file from local machine
Dim mylocalFilePath As String() = Directory.GetFiles(System.Environment.CurrentDirectory & MSI_FOLDER)
myMSIFilePath = mylocalFilePath(0)
myMSIFileName = getFileName(myLocalFilePath(0))
Do While sr.Peek() >= 0
tempServerPath = "\\" & sr.ReadLine() & TEMP_PATH
If Directory.Exists(tempServerPath) Then
'First copy the MSI file to the remote server
File.Copy(myMSIFilePath, tempServerPath & "\" & myMSIFileName, True)
If File.Exists(tempServerPath & "\" & myMSIFileName) Then
writeToLog("==MSI copied to " & tempServerPath)
'Next, install the msi on the server
Dim procinfo As ProcessStartInfo = New ProcessStartInfo()
procinfo.FileName = "msiexec.exe"
procinfo.Arguments = "/q /i " & tempServerPath & "\" & myMSIFileName
Dim proc As New System.Diagnostics.Process
proc = System.Diagnostics.Process.Start(procinfo)
'Wait for the installation to finish
'Code to check if the installation successful???
writeToLog("==MSI copy failed to " & tempServerPath)
writeToLog(tempServerPath & "==folder does not exist")
Catch ex As Exception
writeToLog(tempServerPath & "==>file read failed" & vbLf & ex.Message)