简体   繁体   English

XCOPY无法识别为内部或外部命令

[英]XCOPY not recognized as internal or external command

I am very new to batch file coding. 我是批处理文件编码的新手。 I am trying to use XCOPY for copying some file. 我正在尝试使用XCOPY复制某些文件。 First I used like this: 首先,我这样使用:

@echo off

MOVE mypath\abc.txt mypath\abc.txt.0001
XCOPY mypath\abc.txt.bak mypath\abc.txt

pause

This code is working perfectly fine. 这段代码运行得很好。 Then I needed to take some input from user, o I modified the code like this: 然后,我需要从用户那里获得一些输入,o我修改了这样的代码:

@ECHO off

ECHO Starting application.
SET /p path=Enter the path: 
SET /p corruptFileName=Enter the corrupted file name: 
SET /p oldBackupFileName=Enter the Backup file name to restore: 
SET /p correuptedBackupName=Enter the corrupted backup file name: 

ECHO Path : 
ECHO %path%
ECHO Corrupted file name : 
ECHO %corruptFileName%
ECHO Desired Backup file name:
ECHO %correuptedBackupName%
ECHO Backup file name to restore : 
ECHO %oldBackupFileName%


MOVE %path%\%corruptFileName% %path%\%correuptedBackupName%
call :waitfor 5000>nul
XCOPY %path%\%oldBackupFileName% %path%\%corruptFileName%

PAUSE

This code is not running. 此代码未运行。 It says that : 它说:

The system cannot find the batch label specified - waitfor
'XCOPY' is not recognized as an internal or external command,
operable program or batch file.

Can anyone shed any light in this? 谁能对此有所启示?

Thanks! 谢谢!

%path% is an environment variable that is used to tell the operating system where programs are located. %path%是一个环境变量,用于告诉操作系统程序位于何处。 Without it, you have to give the full path to system executables (like xcopy ) before they can be called by name only. 没有它,您必须给系统可执行文件(如xcopy )提供完整路径,然后才能仅通过名称调用它们。

Never overwrite it. 永远不要覆盖它。

Change the variable name to something else. 将变量名更改为其他名称。 Anything else. 还要别的吗。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM