Object Process

Immanent_Safety

New member
Joined
May 11, 2005
Messages
3
Programming Experience
3-5
I've been looking around the net for some Process code, and I cant find anything that does what I want.

I want to basically call a program (like Shell, or make a process), but I want to be able to (1)run the Calling program while the Called program executes. Then when the called program is done, I need to (2)force a file to print. I think my main thing is that I wanted both programs to run at the same time... here's what I got so far, and the exception that I got.

(I used notepad just for a test run of the command)
processexception1rn.jpg
 
OMG I GOT IT!! :D

Ok, basically I wanted to have my program just call this other program (in this case notepad) and note pad didn't effect the running of my main program, meaning I could still play around with it, while notepad was open.

Also, I wanted my main program to be notified when notepad was done running. (When I get the COBOL program to work with this, I have to wait untill the program is done before I can force the output file to print)

I got it to work, and here is my code (This is just to run notepad, and when notepad gets done running a messagebox wil come up and notify you)

VB.NET:
    Private Sub MenuItem11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem11.Click
        'make the Process object and run it, 
        'also make a Process object out of the returned object
        Dim myProcess As System.Diagnostics.Process = New System.Diagnostics.Process

        'Tell the Process what to open or run, and where it is
        myProcess.StartInfo.FileName = "notepad.exe"

        'This makes the window open up like it normally would
        myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal

        'Enable the exit event to fire.
        myProcess.EnableRaisingEvents = True

        'add event handler for the process
        'run the OnProcessExit Module when the process is done
        AddHandler myProcess.Exited, AddressOf OnProcessExit

        'Start the Process
        myProcess.Start()
    End Sub

    Private Sub OnProcessExit(ByVal sender As Object, ByVal e As EventArgs)
        'Show Confirmation on exit
        MessageBox.Show("Program Exited", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

Here's a really good document on the Process class in VB.NET
Visual Basic.net Arcticle (Process)
 
Back
Top