I am trying to get my application to execute an install program that is located in my TEMP folder in Windows. I fugured the best way to get this process to start would be to use System.Diagnostics.Process.Start(...), however, I keep getting an error. Here is my code:
Unfortunately, when I run the code, I get the following error:
System.ComponentModel.Win32Exception: %1 is not a valid Win32 application
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(String fileName)
at SDCICDB.frmSDCICDB.InstallVersion() in D:\My Documents\Visual Studio Projects\SDCICDB\SDCICDB\frmSDCICDB.vb:line 604
The string that gets passed to "filepath" and "filepath2" is "C:\DOCUME~1\cwinnyk\LOCALS~1\Temp\Setup.Exe"
DOes anyone know what I am doing wrong? Thanks!
Code:
Private Sub InstallVersion()
Cursor = Cursors.WaitCursor
If DownloadVersion() = True Then
Try
Dim filePath As String = Environment.GetEnvironmentVariable("TEMP") & "\Setup.Exe"
System.Diagnostics.Process.Start(filePath)
Catch ex As Exception
Try
Dim filePath2 As String = Environment.GetEnvironmentVariable("TMP") & "\Setup.Exe"
System.Diagnostics.Process.Start(filePath2)
Catch ex2 As Exception
If ReportError(ex2.ToString) = True Then
MsgBox(ex2.Message, MsgBoxStyle.Critical, "Error Reported")
Else
MsgBox(ex2.ToString, MsgBoxStyle.Critical, "Error Please Record the following Information")
End If
End Try
End Try
End If
End Sub
Unfortunately, when I run the code, I get the following error:
System.ComponentModel.Win32Exception: %1 is not a valid Win32 application
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(String fileName)
at SDCICDB.frmSDCICDB.InstallVersion() in D:\My Documents\Visual Studio Projects\SDCICDB\SDCICDB\frmSDCICDB.vb:line 604
The string that gets passed to "filepath" and "filepath2" is "C:\DOCUME~1\cwinnyk\LOCALS~1\Temp\Setup.Exe"
DOes anyone know what I am doing wrong? Thanks!