Results 1 to 8 of 8
  1. #1
    Capevaldo's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Location
    CWBeats
    Posts
    5,523
    Reputation
    242
    Thanks
    1,150
    My Mood
    Drunk

    How to get a process Exit Code?

    Hello guys c:

    So, I'm trying to start a process from VB and get the ExitCode when the process end.
    This process is a C program that can return 0 in case of sucess, -1 or -2 in case of error.
    I would like to manipulate my VB program according to the exit code to show the user what happens and why.

    I tryed using MyProcess.ExitCode (MyProcess is a Process variable), but it says the program should exit before using this code. Then I tryed using MyProcess.Close() and then MyProcess.ExitCode, but it says there was no process attached to MyProcess.

    Anyone know a way to do it?

    Thank you guys and sorry for any grammar error.
    • CABR Minion:
    Feb, 12th 2011 - Aug, 12th 2011

    • Full CA Section Minion:
    July, 06th 2011 - Aug, 12th 2011

  2. #2
    dnj$nda94manbdw's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    World Of Network...
    Posts
    1,343
    Reputation
    88
    Thanks
    1,148
    My Mood
    Angelic
    Me.close()

  3. #3
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    "So, I'm trying to start a process from VB and get the ExitCode when the process end." - Please post code related to process start / exit code checking.

    "I tryed using MyProcess.ExitCode (MyProcess is a Process variable), but it says the program should exit before using this code."
    Is that a problem, or a question? Because it makes sense...it wouldn't HAVE an exit code, until it exits ofc.


    "Then I tryed using MyProcess.Close() and then MyProcess.ExitCode" - what happened?
    Did the target process close? Did the code not compile? Runtime Exception? unexpected value returned?

    Code:
    If MyProcess.HasClosed Then ''//or was  it HasExited? or IsStillRunning? ..find the name.
    'we can get the error code
    Dim _targetProcStatusResult as Int32 = MyProcess.ExitCode
    Else
    'process still running, can't get error code yet.
    End IF
    ''maybe
    Last edited by abuckau907; 01-25-2013 at 06:17 PM.
    'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

  4. #4
    Xzevos's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Posts
    48
    Reputation
    10
    Thanks
    104
    Code:
    Dim p() As Process = Process.GetProcesses
            For Each i As Process In p
                If i.ProcessName = "processname" Then
                    
                End If
    Next i
    That'll be how you would get the process by anme, id, ect..

    Code:
    If MyProcess.HasExited = True Then
    
                End If
    process exited :l

  5. #5
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    op: "So, I'm trying to start a process from VB"

    Code:
    Dim p() As Process = Process.GetProcesses
            For Each i As Process In p
                If i.ProcessName = "processname" Then
                    
                End If
    Next i
    using the above code would return the 'first instance' of the process found running (in-case you have multiple copies open, ever)

    op is probably using Process.Start("C:/theGame.exe") and assigned the return value of that function to some variable. I want to see though. Post some code op :b

    Code:
    MyProcess = Process.Start("C:/theGame.exe")
    ...
    If MyProcess.HasExited = True Then
    'safe to check MyProcess.ExitCode
        ''''return 0 in case of sucess, -1 or -2 in case of error
        If MyProcess.ExitCode = 0 Then
        Msgbox("Target Program closed with 0 errors - All to the good.")
        Else
        MsgBox("Target Program Crashed / Reported Error - ERROR")
        End If
    Else
    'don't check it yet
    End If
    -----------

    "I tryed using MyProcess.ExitCode"
    How/where did you call it? Inside a timer? Or a button_click, or ?
    Idk, but I think as long as you check (apparently have to) .HasExited() = True, it should be ok.

    edit: you can use @Xzevos's code, later, to find the ExitCode of other processes, not just ones you* start. useful.
    Last edited by abuckau907; 01-25-2013 at 09:49 PM.
    'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

  6. #6
    Xzevos's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Posts
    48
    Reputation
    10
    Thanks
    104
    Idk enough information to know how to use the code. He gotta respond now.

  7. #7
    master131's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    Melbourne, Australia
    Posts
    8,858
    Reputation
    3438
    Thanks
    101,670
    My Mood
    Breezy
    Code:
    Dim p As New Process
    p.StartInfo.FileName = "blah.exe"
    p.StartInfo.Arguments = "/blah"
    p.Start
    p.WaitForExit 
    MessageBox.Show(p.ExitCode)
    You probably forgot WaitForExit or something.
    Donate:
    BTC: 1GEny3y5tsYfw8E8A45upK6PKVAEcUDNv9


    Handy Tools/Hacks:
    Extreme Injector v3.7.3
    A powerful and advanced injector in a simple GUI.
    Can scramble DLLs on injection making them harder to detect and even make detected hacks work again!

    Minion Since: 13th January 2011
    Moderator Since: 6th May 2011
    Global Moderator Since: 29th April 2012
    Super User/Unknown Since: 23rd July 2013
    'Game Hacking' Team Since: 30th July 2013

    --My Art--
    [Roxas - Pixel Art, WIP]
    [Natsu - Drawn]
    [Natsu - Coloured]


    All drawings are coloured using Photoshop.

    --Gifts--
    [Kyle]

  8. The Following User Says Thank You to master131 For This Useful Post:

    Capevaldo (01-26-2013)

  9. #8
    Capevaldo's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Location
    CWBeats
    Posts
    5,523
    Reputation
    242
    Thanks
    1,150
    My Mood
    Drunk
    Thanks mate, now everything is running OK c:
    The problem was that WaitForExit thing.
    • CABR Minion:
    Feb, 12th 2011 - Aug, 12th 2011

    • Full CA Section Minion:
    July, 06th 2011 - Aug, 12th 2011

Similar Threads

  1. Replies: 6
    Last Post: 05-31-2014, 10:15 PM
  2. How to get more Gun adder codes?
    By sxycyrz in forum Alliance of Valiant Arms (AVA) Help
    Replies: 3
    Last Post: 08-05-2012, 03:20 AM
  3. How to get black ops serial codes
    By no1joey in forum Call of Duty Black Ops Discussions
    Replies: 13
    Last Post: 02-08-2011, 07:53 AM
  4. [Info] how to get crossfire codes
    By nenab93 in forum CrossFire Hacks & Cheats
    Replies: 6
    Last Post: 01-31-2010, 02:39 AM
  5. how/why did you get into learning a coding language
    By maiyahi1 in forum C++/C Programming
    Replies: 19
    Last Post: 07-24-2009, 11:00 PM