Running command-line in batch file

2019-08-07 02:37发布

I have the following code which doesn't seem to be working properly - is someone able to assist with how to run command-lines in batch files

@echo off

set changeFrom=321
set changeTo=123
set origFile=config.txt
set newFile=config1.txt

test.bat %changeFrom% %changeTo% %origFile%>%newFile%
del %origFile%
ren %newFile% %origFile%

::end

I have a file "test.bat" which has code to replace strings in a file - but I Don't get how it can work ?

1条回答
做个烂人
2楼-- · 2019-08-07 03:22

You need to use call to execute the second bat file from the first like this:

call test.bat %changeFrom% %changeTo% %origFile%>%newFile%

without call the first batch script will exit when the second one exits.

查看更多
登录 后发表回答