此脚本将%programfiles%
或%programfiles(x86)
中的所有文件和文件夹复制到目标文件夹。如果我的windows架构x86,复制%programfiles%
,复制文件/文件夹成功,但如果我的windows架构x64没有。
脚本
@echo Off
set Arch=x64
if "%PROCESSOR_ARCHITECTURE%" == "x86" (
if not defined PROCESSOR_ARCHITEW6432 set Arch=x86
)
echo Arsitektur Prosesor Windows Anda %Arch%
set /P drive=Folder backup akan disimpan di drive apa : %=%
if %Arch% == "x64" (
if not exist "%drive%:\BACKUP_ESPT\C" mkdir "%drive%:\BACKUP_ESPT\C"
if not exist "%drive%:\BACKUP_ESPT\VIRTUALSTORE" mkdir "%drive%:\BACKUP_ESPT\VIRTUALSTORE"
xcopy /Y /S "%ProgramFiles(x86)%\DJP\*.*" "%drive%:\BACKUP_ESPT\C"
xcopy /Y /S "%localappdata%\VirtualStore\Program Files (x86)\DJP\*.*" "%drive%:\BACKUP_ESPT\VIRTUALSTORE"
) else (
if not exist "%drive%:\BACKUP_ESPT\C" mkdir "%drive%:\BACKUP_ESPT\C"
if not exist "%drive%:\BACKUP_ESPT\VIRTUALSTORE" mkdir "%drive%:\BACKUP_ESPT\VIRTUALSTORE"
xcopy /y /S "%ProgramFiles%\DJP\*.*" "%drive%:\BACKUP_ESPT\C"
xcopy /y /S "%localappdata%\VirtualStore\Program Files\DJP\*.*" "%drive%:\BACKUP_ESPT\VIRTUALSTORE"
)
ECHO Proses Backup e-SPT selesai
pause
结果
Arsitektur Prosesor Windows Anda x64
Folder backup akan disimpan di drive apa : D
File not found - *.*
0 File(s) copied
File not found - *.*
0 File(s) copied
Proses Backup e-SPT selesai
Press any key to continue . . .
怎么了?请帮我。感谢
答案 0 :(得分:0)
我正在查看您的脚本,如果我错了,请更正我,但当处理器架构是x64时,您将访问x86文件夹(如您的情况)。这就是你想要的吗?
顺便说一下:你正在使用/ s选项进行xcopy。这是复制整个目录的选项。您不需要*.*
后缀:只需指定目录,它就会完全复制。
答案 1 :(得分:0)
if %Arch% == "x64" (
应该是
if "%Arch%"=="x64" (
字符串匹配绝对是字面的; x64
和"x64"
不是一回事,因此else
分支将被占用并且目标不存在。