Click here to Skip to main content
11,704,768 members (53,531 online)
Rate this: bad
Please Sign up or sign in to vote.
Hi. I want to use to execute a program (*.exe file), wait till it finishes and get the return value the *.exe program returns. Now I did accomplish this using the code bellow however the error code i get the first few tries is correct but then i keep getting 0xCDCDCDCD as the error code. I don't understand why running this code would generate the wrong result after few tries. Please help.
How can i ensure i get the correct exit code
Ps. the *.exe file was writen in c++ and it always returns a positive integer where as 0xCDCDCDCD is negative as a signed integer representation

Dim startInfo As New System.Diagnostics.ProcessStartInfo
Dim MyProces As Process
startInfo.FileName = myExeFileName
startInfo.Arguments = myExeArgString
startInfo.CreateNoWindow = True
startInfo.UseShellExecute = True
startInfo.WindowStyle = ProcessWindowStyle.Hidden
MyProces = Process.Start(startInfo)
If (MyProces.ExitCode <> 0) Then
  MsgBox("0x" + Hex(MyProces.ExitCode()))
End If
Posted 3-Mar-11 13:31pm
Edited 3-Mar-11 14:44pm
Henry Minute224.6K

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The Process class has an ExitCode property. Example here[^].

I think that is what you need. Smile | :)
SAKryukov at 3-Mar-11 21:47pm
Yes, that's it, my 5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 658
1 OriginalGriff 485
2 Andy Lanng 275
3 CPallini 242
4 Maciej Los 225
0 OriginalGriff 8,864
1 Sergey Alexandrovich Kryukov 8,245
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,606

Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 3 Mar 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100