Shell Call

AddOn to MultipleExes.

I have had a hard time with the call Shell (in VB6):

  Shell programPath & fileToOpen, vbNormalFocus 
just won't work,

This has to be written as:

  Shell programPath & " " & fileToOpen, vbNormalFocus 

So a space is required between the programPath and the fileToOpen (or Command$).

Next it will run fine but then suddenly errors occur. This is caused by a space within the programPath itself, e.g.:

 programPath="C:Folder\Sub Folder\my app.exe" 
will be read as

You have to add """" to the string to solve this.

So you have to write:

  Shell chr(34) & programPath & chr(34) & " " &  chr(34) & fileToOpen  & chr(34)
This will work fine.

In VB6 you can handle the string chr(34) & fileToOpen & chr(34) as Command$ by the program that is called, so you can write code like:

 if Command$ <> "" then ... else...  
This is also the easy way to pass all kind of information to another exe, when you use MultipleExes.


Apart from Shell, you can also use the api ShellExecute?, this will open any file in the the program it's associated to.


Category VisualBasic


EditText of this page (last edited May 21, 2004) or FindPage with title or text search