此脚本用于将%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_ESPTC" mkdir "%drive%:BACKUP_ESPTC"
if not exist "%drive%:BACKUP_ESPTVIRTUALSTORE" mkdir "%drive%:BACKUP_ESPTVIRTUALSTORE"
xcopy /Y /S "%ProgramFiles(x86)%DJP*.*" "%drive%:BACKUP_ESPTC"
xcopy /Y /S "%localappdata%VirtualStoreProgram Files (x86)DJP*.*" "%drive%:BACKUP_ESPTVIRTUALSTORE"
) else (
if not exist "%drive%:BACKUP_ESPTC" mkdir "%drive%:BACKUP_ESPTC"
if not exist "%drive%:BACKUP_ESPTVIRTUALSTORE" mkdir "%drive%:BACKUP_ESPTVIRTUALSTORE"
xcopy /y /S "%ProgramFiles%DJP*.*" "%drive%:BACKUP_ESPTC"
xcopy /y /S "%localappdata%VirtualStoreProgram FilesDJP*.*" "%drive%:BACKUP_ESPTVIRTUALSTORE"
)
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 . . .
怎么了?请纠正我。感谢
我正在查看您的脚本,如果我错了,请纠正我,但当处理器架构为x64时,则您正在访问x86文件夹(就像您的情况一样)。这就是你想要的吗?
顺便说一句:您正在为xcopy使用/s选项。这是复制整个目录的选项。那么,您不需要*.*
后缀:只需指定目录,它就会完全复制它。
if %Arch% == "x64" (
应该是
if "%Arch%"=="x64" (
字符串匹配绝对是字面意思;x64
和"x64"
不是同一个东西,所以会采取else
分支,并且目标不存在。