Home All Groups Group Topic Archive Search About

Starting process using shell execute returns nothing

Author
19 Oct 2006 1:01 AM
Zorpiedoman
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????


--
--Zorpie

Author
19 Oct 2006 1:24 AM
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)
Author
19 Oct 2006 1:36 AM
Zorpiedoman
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.
--
--Zorpie


Show quoteHide quote
"mali***@verizon.net" wrote:

> Did you try this code?
>
> Dim q As Process
>
> q = Process.Start("C:\windows\Notepad.exe")
> q.WaitForExit()
> Console.WriteLine("Exit Time:" & q.ExitTime)
>
Author
19 Oct 2006 2:13 AM
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
Author
19 Oct 2006 1:25 PM
Zorpiedoman
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.
--
--Zorpie


Show quoteHide quote
"mali***@verizon.net" wrote:

> 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
>