Ian Dimock
Ian Dimock

Reputation: 1

Problems with call in cmd

My problem is the following. Within a batch file I am writing I make a call to another batch file in the same directory:

CALL batch2.bat parameter1 parameter2

This seemed to work fine up until I placed the batch files in a directory whose path contained spaces.

c:\My Batch Files\

for example. I am getting the error message: The system cannot find the path specified.

Things I've tried to no effect. Quoting the absolute path in the call statement

CALL "C:\My Batch Files\batch2.bat" parameter1 parameter2

CALL "%CD%\batch2.bat" parameter1 parameter2

Is there a way to accomplish my task in a directory whose path contains spaces? Please let me know if any more information is required.

Upvotes: 0

Views: 260

Answers (1)

Dave
Dave

Reputation: 1072

You could change the working directory to your script location in the first .bat

C:

CD "C:\My Batch Files"

CALL batch2.bat parameter1 parameter2

Although, I tested your example (CALL "C:\My Batch Files\batch2.bat" parameter1 parameter2) on Windows 7 and Windows XP SP3 and both worked fine. What OS are you testing on?

Upvotes: 3

Related Questions