"Pegasus [MVP]" <> wrote in message
news:...
>
> "Synapse Syndrome [KGB]" <> wrote in message
> news:...
>> Pegasus [MVP] <> wrote:
>>>>
>>>> I am trying to make a .cmd script execute a program (a text editor),
>>>> and then do other stuff, but it will not continue until that program
>>>> has
>>>> been closed.
>>>>
>>>> I have tried using the CMD command itself, with the /s switch, but
>>>> that is not working in any way that I understand.
>>>>
>>>> How can I do this?
>>>>
>>>> Cheers
>>>
>>> Use the Start command, e.g.
>>>
>>> start /b notepad.exe
>>>
>>> Type start /? to see the various switches.
>>
>> Hello again
>>
>> I still cannot get it to work with the particular text editor that I am
>> using. Something weird is going on.
>>
>> start /b /i "%programfiles%\JGsoft\EditPadPro6\EditPadPro. exe" "%1"
>>
>> I am using the /i switch because it is being run from a CMD instance
>> which is RUNAS adminitrator, but I do not think that this has anything to
>> do with it not working, as I tried with the current environment as well.
>>
>> ss.
>
> Since the path to your executable contains spaces, you MUST use the
> "Title" parameter:
Not exactly. The "title" parameter is required when the pathname of the
executable is contained within double quotes. The quotes are only required
when the executable pathname contains spaces, but they are optional and
always allowed. In fact, one might include them when the pathname is
determined at runtime, in which case one might not know in advance whether
or not spaces are involved.
If that seems an obtuse explanation, look at it from the point of view of
the start command itself: if the first parameter starts with a double quote,
it must be the "title" parameter, in which case executable is given by the
second parameter. Some examples:
these are OK:
start notepad.exe test.cmd
start "" "notepad.exe" test.cmd
start "" notepad.exe test.cmd
this is wrong:
start "notepad.exe" test.cmd
Actually, that is a completely valid command, it just does something you
might not expect. It starts a batch file with the title argument set to
"notepad.exe".
My suggestion to avoid such a gaffe is to always include a title and always
enclose the executable in quotes. If the title is not used for any purpose
by the executable, just give it as "".
> start /b /i "Synapse's App"
> "%programfiles%\JGsoft\EditPadPro6\EditPadPro. exe" "%1"
Note that if the first parameter to the batch file is given enclosed in
quotes (i.e. "file to edit.txt" the above command will pass the name to the
executable as ""file to edit.txt"". The simplest fix is to use this syntax:
> start /b /i "Synapse's App"
> "%programfiles%\JGsoft\EditPadPro6\EditPadPro. exe" "%~1"
The "~" will strip leading/trailing double quotes, but only if the are
present.
/Al
|