This bit of code produces a blank message box:
Dim
MyProcess As New ProcessDim startInfo As New ProcessStartInfo("notepad.exe")MyProcess = Process.Start(startInfo)
MsgBox(MyProcess.MainWindowTitle.ToString)
Any sebsequent attempt to access any MyProcess property comes up with nothing.
This produces a message box with the expected text:
Dim
MyProcess As New ProcessDim startInfo As New ProcessStartInfo("notepad.exe")MyProcess = Process.Start(startInfo)
While MyProcess.MainWindowTitle.ToString = ""MyProcess.Refresh()
Threading.Thread.Sleep(100)
End WhileMsgBox(MyProcess.MainWindowTitle.ToString)
Why would process.start() return an object with none of the properties set

Process.start not behaving as expected
RENE ROMAN
WaitForInputIdle almost works.
Seems to depend on the application.
With notepad.exe it's fine. With mstsc.exe (remote desktop) I get nothing in MainWindowTitle. I DO get id however, which is what I'm really after so I'm happy. I didn't know the process info was cached, thanks for the tip.
Michael Hulthin
Process.Start() does not wait for the UI to come up, so for processes with a UI you should call WaitForInputIdle() after Start(). This causes a wait until the specified process is waiting for a user input with no input pending.
Is this the exact sample code that you tried I'd be surprised if this did not work, please let me know if it does not.
Dim MyProcess As New Process Dim startInfo As New ProcessStartInfo("notepad.exe")MyProcess = Process.Start(startInfo)
MyProcess.WaitForInputIdle()
MsgBox(MyProcess.MainWindowTitle.ToString)
The interesting thing about the Process class however is that it caches data.
For example, if you were to use:
Dim MyProcess As New Process Dim startInfo As New ProcessStartInfo("notepad.exe")MyProcess = Process.Start(startInfo)
MsgBox(MyProcess.MainWindowTitle.ToString)
MyProcess.WaitForInputIdle()
MsgBox(MyProcess.MainWindowTitle.ToString)
Both he first AND second message boxes would return an empty string, the reason being that the first call to MyProcess.MainWindowTitle would return an empty string that would be cached for subsequent calls to MyProcess.MainWindowTitle.
Adding a MyProcess.Refresh() prior to the second call to MyProcess.MainWindowTitle would fix this.
Danny Shisler
Yeah, tried that. Did not work.
Why would it return before the process is created if it returns an object that represents that process
RyanBay
The process did not have a chance of actually starting yet.
Instead of the while-loop, call MyProcess.WaitForInputIdle().
s