Launch External Apps

Phreak

Well-known member
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!
 
Code:
Process.Start("C:\Program Files\Whatever\Blah.exe")
 
To get the applications path, you can use a combination of
Application.ExecutablePath and the GetDirectoryName method
of the Path class.

Code:
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 doesnt like what I have below.

Code:
Process.Start("C:\ORANT\BIN\PLUS80W.EXE @ " & Application.StartupPath & "\seedlistp1.sql")
 
Well, I found out how to enter arguments in with the PROCESS.START. However, it still wants to use the 8.3 format for the arguments. Any help? Ideas?
 
Try enclosing the file path part of the arguments in double quotes.
 
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:
Code:
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 youre inserting quotes into a string and not
just ending the string. Its like \" in C.
 
No dice. This is REALLY agrivating! I thought that last option would have worked, and I cant believe I didnt think of that. Any other ideas? Because now, I"m really stumped.
 
GOT IT!

Code:
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 thats 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 isnt 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
 
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