Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System.Diagnostics.Process.Start: Win32 Exception Error

Status
Not open for further replies.

cwinnyk

Programmer
May 27, 2003
62
US
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:

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! :)
 
what happens if you first check that the file exists?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top