简体   繁体   中英

xcopy in Windows x64 : File not found

This script to copy All file and folder in %programfiles% or %programfiles(x86) to destination folder. if my windows architecture x86, copy %programfiles% , copying file/folder successful, but not if my windows architecture x64.

Script

@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

Result

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 . . .

what's wrong? correct me please. thanks

I am looking at your script, and correct me if I am wrong, but when the processor architecture is x64, then you're accessing the x86 folders (as in your case). Is that what you want?

By the way: you are using the /s option for xcopy. That is the option to copy entire directories. You don't need the *.* postfix then: just specify the directory and it'll copy it entirely.

 if %Arch% == "x64"  (

should be

if "%Arch%"=="x64"  (

A string-match is absolutely literal; x64 and "x64" are not the same thing, so the else branch would be taken and the targets don't exist.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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