0

I'm trying to write my first batch script and trying to understand how to pass arguments. It's a very simple command which runs fine in cmd.

Command: C:\Program Files\Foo> myexe -sd tempVar >> C:\temp.txt

Here -sd is command option and tempVar is another parameter (I know this tempVar value and can hard code in batch script).

Batch Script
Start "C:\Program Files\Foo\myexe.exe" -sd tempVar

Error While executing about batch file, I get an error stating -sd is not recognized. Please suggest what should I work/correct in this script?

1 Answer 1

1

The first parameter to the start command is text to display in the window's title bar, and this value is in quotes. So, in your case, start thinks you want the window title to say C:\Program Files\Foo\myexe.exe. Then, you're passing -sd tempVar to the start command, and it has no idea what that means, as they are not valid parameters for start.

Try this instead...

Start "" "C:\Program Files\Foo\myexe.exe" -sd tempVar
2
  • Thanks @Patrick. Silly mistake on my part. Got output on Console, now going to work on redirecting output to a text file.
    – Rohit
    Aug 12, 2014 at 22:45
  • Also, if you want to do anything else AFTER that line in the batch file, you might want to add the /wait function, or the batch file will continue doing what it's doing before your exe file has finished it's job: Start /wait "" "C:\Program Files\Foo\myexe.exe" -sd tempVar
    – Nate
    Aug 12, 2014 at 22:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .