What the Shell is wrong here?

Richard K. Herz herz at ucsd.edu
Wed May 21 12:31:01 CDT 2003

Below is what I got to work on Win 98 and XP with MC/Rev shell() for paths
with spaces.

Rich Herz
herz at ucsd.edu

Things differ between command.com (default on Win 98) and cmd.exe (default
on Win XP).  XP also has command.com but its features on XP differ somewhat
from those on Win 98.  Check MC global shellCommand value to find out
which is active.  For both, the MC shell("xxx") requires quotes around the
entire single input parameter xxx.  In both examples below tWinPath is a
path that can contain spaces.

FOR COMMAND.COM (default on Win 98)

Command.com requires quotes around paths with spaces in them.  I write a
batch file and do "cd" with quotes around path followed by a command in
batch file to execute myApp.exe file and finally have MC shell() execute the
batch file. The command continuation character in command.com is | but it
doesn't help because you need quotes around entire MC shell() input AND
around path for "cd"

put "C:\temp_mc.bat" into tBatPath
put "file:" & tBatPath into tBatUrl
put "cd" && quote & tWinPath & quote into temp
put cr & "myApp.exe" & cr after temp
  put temp into url tBatUrl
  catch errornum
  answer "Error: can't write command file to C:\ and so can't run!"
  exit to metacard
end try

put "get shell(" & quote & "start" && tBatPath & quote & ")" into

do todo
if there is a file tBatPath then delete file tBatPath

FOR CMD.EXE (default on Win XP)

Cmd.exe can handle spaces in path names and you can put more than one
command into a single shell() using the cmd.exe continuation character &
(see the & just before the word start below).  Here is code to cd to a
directory and then start an executable.  I guess one could do this with only
start and then full path to executable but I stopped coding when I got
things working:

put "get shell(" & quote & "cd" && tWinPath & "& start myApp.exe" & quote &
")" into todo

do todo

More information about the use-livecode mailing list