Jump to content
Xtreme .Net Talk

How do you launch an external application from .net?


Recommended Posts

  • 3 weeks later...
  • *Experts*
Posted

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

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

  • *Gurus*
Posted

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.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

  • *Experts*
Posted

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

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...