MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Calling .exe with Arguments - Run[] Issue

  • To: mathgroup at
  • Subject: [mg66032] Calling .exe with Arguments - Run[] Issue
  • From: Shyam Guthikonda <shyamguth at>
  • Date: Thu, 27 Apr 2006 02:26:34 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

Ugh.. I've spent the past couple hours trying to figure this out. No 
luck in the archives either.

This works (Windows XP, Mathematica 5.2), passing the string OK as the 
first argument to the C program:

Run[ InputForm[ folderName<>"\\"<>exeName ], "OK" ];

This does not work:

Run[ InputForm[ folderName<>"\\"<>exeName ], "\"OK\"" ];

What I am trying to do in the 2nd example is pass "OK" (with the quotes) 
as the first argument to the C program. This is needed, because this 
argument will have spaces in it, so it must be wrapped in quotes to be 
passed as a single argument.

The first command passed to Run[] is a directory name (with spaces) with 
an .exe name concatenated on the end. This first command is surrounded 
in quotes, and this works just fine. But the minute I add quotes the 2nd 
argument, it seems to be ignoring the quotes around the first command; 
It hits a space in the first command and spits out an unrecognized error.

This is odd because the output provided by InputForm[] is correct. If I 
type the output directly in the DOS command window, it works as it's 
supposed to, but not so in Mathematica.

An example of the text provided to me by InputForm[] which works 
perfectly in the DOS console is:

 > "C:\\test dir\\prog.exe" "C:\\arg dir"

What's going on?

Thanks for any help!

  • Prev by Date: Re: Illusory Multicore Support in 5.2?
  • Next by Date: Re: Setting up equations (Revision)
  • Previous by thread: Re: Selecting table rows
  • Next by thread: Re: Calling .exe with Arguments - Run[] Issue