Maciej Cygan
Maciej Cygan

Reputation: 5471

.Batch file does not like variable for php executable

I have a batch file which is going to be called by Windows Task Scheduler to execute given .php file.

However there seems to be a problem because when I provide full path to php.exe i.e.

start /B /wait C:\xampp\php\php.exe -f %inputTask% >> %outputDir%

batch file executes as it should, but when I try to give variable like so:

set php="C:\xampp\php"
start /B /wait C:\xampp\php\php.exe -f %inputTask% >> %outputDir%

if fails given the following error :

Windows cannot find '-f'. Make sure you type the name correctly, and then try again.

Upvotes: 0

Views: 129

Answers (1)

JosefZ
JosefZ

Reputation: 30258

Start command considers the first double-quoted parameter to be a window title...

START: Start a program, command or batch script (opens in a new window.)

Syntax

  START "title" [/D path] [options] "command" [parameters]

Always include a TITLE this can be a simple string like "My Script" or just a pair of empty quotes "". According to the Microsoft documentation, the title is optional, but depending on the other options chosen you can have problems if it is omitted.

Upvotes: 2

Related Questions