Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling an app using shell (With spaces in directory path) 1

Status
Not open for further replies.

Bloobird

Programmer
Oct 23, 2001
49
GB
Hi - I want to use the shell command to call an application, however the path to the app had a directory with 2 words seperated by spaces, which shell does not like. Is there a way of getting around this, other than using an environment variable ?

Thanks
 
this might help

Code:
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long
Public Function GetShortPath(strFileName As String) As String
    'KPD-Team 1999
    'URL: [URL unfurl="true"]http://www.allapi.net/[/URL]
    'E-Mail: KPDTeam@Allapi.net
    Dim lngRes As Long, strPath As String
    'Create a buffer
    strPath = String$(165, 0)
    'retrieve the short pathname
    lngRes = GetShortPathName(strFileName, strPath, 164)
    'remove all unnecessary chr$(0)'s
    GetShortPath = Left$(strPath, lngRes)
End Function
Private Sub Form_Load()
    MsgBox GetShortPath("c:\Program Files\")
End Sub
 
Try looking at ShellExecute:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd&, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd&)&

It takes separate parameters for the executable and the document file names.
 
Hi - Could you send me an example of a call to the ShellExecute command ?

Thanks
 
dear bloobird


did you try

shell("""path/path upps/my.exe"" arguments")


does it work??

regards Astrid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top