Launch External Apps

Phreak

Regular
Joined
Jun 7, 2002
Messages
62
Location
Iowa, United States
Is there a way to launch an external application without using SHELL? Because when I use shell I have to use the 8 char format, e.g. "C:\Progra~1\.....".

When I want to be able to use Application.StartupPath which would return "C:\Program Files\....". Please help!
 
To get the application's path, you can use a combination of
Application.ExecutablePath and the GetDirectoryName method
of the Path class.

Visual Basic:
Dim appPath As String

appPath = Path.GetDirectoryName(Application.ExecutablePath)

[edit]Or use Application.StartupPath... Sorry, missed that part of the post.:o [/edit]
 
How do I use switches with that? Say I want to run a SQL script when I start it. It doesn't like what I have below.

Visual Basic:
Process.Start("C:\ORANT\BIN\PLUS80W.EXE @ " & Application.StartupPath & "\seedlistp1.sql")
 
Just to clear up what divil is saying, most programs, when they accept
command line arguments, require quotes around the arguments if
they are multi-worded.

For example, in the command prompt, to change directories, you
type cd "C:\Program Files\Microsoft Visual Studio .NET", otherwise,
it will take you to C:\Program if it exists.

To open a file in notepad, it might be
notepad.exe "C:\Documents And Settings\Joe\My Documents\notes.txt".

So your line might be like this:
Visual Basic:
Process.Start("C:\ORANT\BIN\PLUS80W.EXE", "@ """ & Application.StartupPath & "\seedlistp1.sql""")
No guarantees that it will work though, of course.

BTW, the double quotes are just because you need to use two to
tell the compiler that you're inserting quotes into a string and not
just ending the string. It's like \" in C.
 
No dice. This is REALLY agrivating! I thought that last option would have worked, and I can't believe I didn't think of that. Any other ideas? Because now, I"m really stumped.
 
GOT IT!

Visual Basic:
Process.Start("C:\ORANT\BIN\PLUS80W.EXE", "@ '" & Application.StartupPath & "\seedlistp1.sql'")

Thanks for all your help and getting me on the right track. However, the program SQL Plus 8, only allows for 79 characters in the argument. But it will work from the Program Files distribution folder so that's all that matters. Thanks again!
 
If all else fails, you can use the GetShortPathName API to get the path in 8.3 format, which will definitely work. As far as I know, this API isn't wrapped in the framework.
 
Im a newbie, and its not tested... but HTML urls often use keys like this %2 g% and something for spesial keys liek norwegian ø

I think space is %20 or 20% try to use that instead of ' ' (space)
 
Just following on with this thread - How do you collect the arguments in VB.NET (command$ in vb 6)

========
System.Diagnostics.Process.Start("foo.exe", "test")
========

I need the string value of test within the foo executable

Cheers
gs
 
Back
Top