Process.Start - What is the difference?

CoachBarker

Well-known member
Joined
Jul 26, 2007
Messages
133
Programming Experience
1-3
When I run this fiunction:

VB.NET:
Dim prc As New Process
prc = Process.Start("rasphone.exe")
prc.WaitForExit()

The Connection Manager opens, then the VPN Login Form opens and after the user has logged in and made a connection my form opens. But if I try to do this:

VB.NET:
Dim prc As New Process
prc = Process.Start("C:\Documents and Settings\All Users\Desktop\Shortcut to Syracuse University VPN.lnk")
prc.WaitForExit()

The Login form for the VPN opens, I get an error message saying Wait For Exit is not set to an instance of an object, and my form opens on top of the Login form.

Any Ideas
CoachBarker
 
When referring to the desktop it is good practice to do so like this

VB.NET:
        Dim desktopFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)

Secondly, I do not think that a shortcut is a process technically and this is why it is not set to the instance of an object. The process object does not work with shortcuts only executables. Therefore, you must point to the executable.
 
Last edited:
Thank you for clearing that up, I knew the VPN was not a process so I should have figured that out. And does declaring the desktop folder that resolve issues about where the lnk file might be on other computers?

Thanks again
CoachBarker
 
Yes, but you should not point it to there. You should point it to the executable.

The GetFolder method is used to retrieve the path of various windows system folders. You should use that to retrieve whichever system folder the executable will reside in.
 
Back
Top