Starting process using shell execute returns nothing

G

Guest

dim FileName as string = "Test.doc"
dim P as Process = Process.Start(FileName)
'--P is NOTHING even though document opens!!!

dim Q as new process
Q.StartInfo.FileName = FileName
P = Q.start
'--P is nothing here, either

WHY????
 
M

maligui

Did you try this code?

Dim q As Process

q = Process.Start("C:\windows\Notepad.exe")
q.WaitForExit()
Console.WriteLine("Exit Time:" & q.ExitTime)
 
G

Guest

That would work fine because you are launching an executable. By launching a
..doc file it uses ShellExecute and does not seem to return a process. This
is what I don't get.
 
M

maligui

As far as I can tell, since vb2003. you can use the 'proccess.start' method
to launch any program with it's dedicated exe.

For example

Dim q As New Process

Dim ofd As New OpenFileDialog

ofd.Filter = "Doc Files|*.doc"
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
q = Process.Start(ofd.FileName)

Console.WriteLine("Process Name:" & q.ProcessName)
q.WaitForExit()
End If

Console.WriteLine("Exit Time:" & q.ExitTime)

Console wrote:
Process Name:WINWORD
Exit Time:10/18/2006 10:11:14 PM
 
G

Guest

Yes, the program starts. That is not the problem. I'm trying to get
notified when the user closes down the launched window. To do that I need
the process to exist so it can raise the exited event, but the process
returned after the launch takes plase is NOTHING, so I can't catch the event.

Sorry, I guess I was not clear enough.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top