开发者

Concatenating input parameters as variables for use inside batch file

command line parameters are either fed to and read by batch file or hard coded in batch file

Set Target_computer = %1
REM  Get Source URL
Set SOURCE_URL = %2
REM Set Source Directory
SET SOURCE_DIR = \reference_data_update

and display when bat file executes. However, when two of them are concatenated

xcopy %SOURCE_URL%%SOURCE_DIR% d:\dqxi\11_7\reference_data /Y/H/S/R

they are not read. The command echoes as

xcopy   开发者_运维百科 d:\dqxi\11_7\reference_data /Y/H/S/R

How can I get these variables to work in the batch file to perform the work I need the bat file to perform (xcopy from the source server's reference_data_update directory to the target server's reference_data directory)?


try removing the spaces (near the set command)

@echo off
Set Target_computer=%1
REM  Get Source URL
Set SOURCE_URL=%2
REM Set Source Directory
SET SOURCE_DIR=\reference_data_update
::and display when bat file executes. However, when two of them are concatenated

echo %SOURCE_URL%%SOURCE_DIR% d:\dqxi\11_7\reference_data /Y/H/S/R


Remove the spaces before and after your equals signs in you SET statements.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜