How do you launch an external application from .net?

This one worked just great for me...

If OpenDocument("C:\Winnt\system32\calc.exe") = False Then
OpenDocument("C:\Windows\system32\calc.exe")
End If
End Sub
Public Function OpenDocument(ByVal DocName As String) As Boolean
Try
Start(DocName)
Return True
Catch
Return False
End Try
End Function:D
 
I don't know exactly what that code is supposed to do, but it isn't very good. To start with, you're hardcoding Windows paths, which is a big no no. Then you seem to be calling some Start function which doesn't actually exist, unless you've imported something I'm not aware of, in which case you need to specify.

Bottom line, to anyone reading this, ignore the code posted above and use the Process.Start function.
 
I would guess he just typed it in manually and it should be "Process.Start", assuming a "using" statement for System.Diagnostics. I'm not sure the equivalent word in VB.NET to using, Imports maybe?

As for the paths, you can use Environment.SystemDirectory to get the path to c:\winnt\system32 or c:\windows\system32 or wherever it is.

-ner
 
Back
Top