Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
RUN a exe whose path contains spaces
Message
From
22/10/1997 10:21:35
 
 
To
22/10/1997 09:46:28
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00055090
Message ID:
00056022
Views:
38
>>>>>>>>>I have a problem where I need to run a program that potentially resides in a directory such c:\Program Files\blah blah\the.exe.
>>>>>>>>>
>>>>>>>>>I'm currently building the run command in a quoted variable and executing the run with a macro as follows:
>>>>>>>>>
>>>>>>>>>xCmnd = '"' + GetTheProgram() + ' ' + GetParameters() + '''
>>>>>>>>>&& xCmnd would look like "C:\Program Files\Blah Blah\The.exe C:\Program Files\Blah Blah\AnotherFileName"
>>>>>>>>>RUN &xCmnd
>>>>>>>>>
>>>>>>>>>Fail
>>>>>>>>>
>>>>>>>>>If, however xCmnd looked like "C:\Blah\The.exe C:\Program Files\Blah Blah\AnotherFileName" it works.
>>>>>>>>>
>>>>>>>>>It appears the parses takes to the first space as the executable file for the run command. Anyone know how to solve this problem.
>>>>>>>>
>>>>>>>>I have had some problems like this before. Now, I am always using the RUN inside the macro so I now call the macro like this:
>>>>>>>>
>>>>>>>>LOCAL lcExec
>>>>>>>>lcExec='RUN '+everythingyouneedhere...
>>>>>>>>&lcExec
>>>>>>>
>>>>>>>I'll Let you know in about 5 minutes if it works.
>>>>>>>
>>>>>>>Thanks
>>>>>>>
>>>>>>>Bill Wilson
>>>>>>>sharbot.com
>>>>>>
>>>>>>Nope. Same results. If I move the exe to another directory where there are no spaces in the tree names it will work.
>>>>>>
>>>>>>What is interesting is that the parameters passed to the exe can contain paths with spaces and all works (providing I further embed those parameters in quotes.
>>>>>>
>>>>>>Any other suggestions (other than WIN API stuff?
>>>>>>
>>>>>>TIA
>>>>>>
>>>>>>Bill Wilson
>>>>>>Sharbot.com
>>>>>
>>>>>Have you tried using the MS-DOS path names:
>>>>> Example:
>>>>> Win path = 'c:\Program Files\blah blah\the.exe'
>>>>> Dos path = 'c:\progra~1\blah~1\the.exe'
>>>>>If you go into dos on WIN95 and do a dir one side is the long
>>>>>file name and the other is short file name try useing the short
>>>>>file name.
>>>>
>>>>Without knowing the names ahead of time, do you have a suggestion on how I could acquire the 8.3 file name dynamically? It woulds be the solution I need.
>>>>
>>>>Thanks
>>>>
>>>>Bill Wilson
>>>
>>>The following way seems to work:
>>>SET DEFAULT TO "C:\Program Files\blah\blah"
>>>Run The.Exe
>>
>>The problem with SET DEFAULT TO is that I am using it to set the location of the output of the file that I'm running. In other words the .EXE tha I'm running creates output. This output defaults to the current directory (I cannot pass that information to the EXE), consequently, I must access the EXE via it's path because I have positioned the user in output destination directory.
>>
>>Thanks,
>>
>>Bill Wilson
>
>Make your life easier, e.g. create file in the same dir as exe, and then COPY FILE.

I solved my problem by doing a call to GSPN:

DECLARE INTEGER GetShortPathName IN kernel32 AS GSPN;
STRING cLongPath, ;
STRING @ cShortPath,;
INTEGER nsize

cShort = SPACE( 250 )
nSize = GSPN( , @cShortPath, 250 )
cShortPath = LEFT( cShortPath, nSize ) &&truncate the nulls

and then I use the macro of cShortPath along with parameters for the run command.

Thanks for your suggestion.

Bill Wilson
Previous
Reply
Map
View

Click here to load this message in the networking platform