What’s happening with the read is that the cmd process just isn’t returning anything at all – the read is getting stuck like with a null pointer. Once you read past the DOS prompt, there’s just nothing there. We’ve come up with a workaround which involves just reading to the next occurrence of the prompt. To facilitate that, you need to start by sending a command to set the prompt to something that is easy to recognize; I chose “+>”, but you can set it to be almost anything (see http://www.chami.com/tips/windows/020497W.html). I then wrote a function that I could just pass the command to run to in order to eliminate all the redundant code for reading and writing.
global prompt
set prompt to return & "+>"
open process "cmd"
put runCommand "PROMPT +$g"
put runCommand "chdir C:\Users\support\" put runCommand "dir"
function runCommand command
global prompt
write command & return to process "cmd" read from process "cmd" until prompt
return it
end runCommand
For your second question, the options need to be a property list, with specific properties such as “directory” and “parameters”. To pass parameters the correct syntax would be:
open process "cmd" with options (parameters:("/k", "<prog>", "<prog>"))