开发者

Concatenating input parameters as variables for use inside batch file

开发者 https://www.devze.com 2023-03-06 00:23 出处:网络
command line parameters are either fed to and read by batch file or hard coded in batch file Set Target_computer = %1

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

精彩评论

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