tags:

views:

495

answers:

2

I'm trying to use a batch file to help setup a build project. As part of that process I need to copy a lot of files from a temporary directory: %temp%\wcu to a new directory in the %programfiles% directory.

I am using the following command:

xcopy %temp%\wcu\dotnetframework\*.* %programfiles%\"Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFx35SP1" /S

Of course the problem is that %programfiles% equates to "C:\Program Files" with a space and so xcopy throws a wobbly.

Any ideas on how to get around this?

+2  A: 

use quotes

xcopy "%temp%\wcu\dotnetframework\*.*" "%programfiles%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFx35SP1" /S
Shay Erlichmen
Actually this one seems to work, which surprised me as I would have thought that the quote marks would have overridden the % sign.
ChrisBD
A: 

"Use quotes", like Shay Erlichmen said, but remember: inside batch files, your environment variables should be preceded by an extra % sign:

xcopy "%%temp%\wcu\dotnetframework\*.*" "%%programfiles%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFx35SP1" /S
Rubens Farias