Me.close()
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
"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.
--
That'll be how you would get the process by anme, id, ect..Code:Dim p() As Process = Process.GetProcesses For Each i As Process In p If i.ProcessName = "processname" Then End If Next i
process exited :lCode:If MyProcess.HasExited = True Then End If
op: "So, I'm trying to start a process from VB"
using the above code would return the 'first instance' of the process found running (in-case you have multiple copies open, ever)Code:Dim p() As Process = Process.GetProcesses For Each i As Process In p If i.ProcessName = "processname" Then End If Next i
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.
--
Idk enough information to know how to use the code. He gotta respond now.
You probably forgot WaitForExit or something.Code:Dim p As New Process p.StartInfo.FileName = "blah.exe" p.StartInfo.Arguments = "/blah" p.Start p.WaitForExit MessageBox.Show(p.ExitCode)
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]
Capevaldo (01-26-2013)
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