当你有很多的32位和64位操作系统的电脑时,如何select“程序文件”文件夹?

如果您拥有32位和64位操作系统以及32位或64位应用程序的大量电脑,如何select“程序文件”文件夹?

我做了一个文件来创build一个火鸟数据库的备份,但我需要帮助。 有时候有一台64位的操作系统和32位的firebird或winrar。 有时候,有一个64位操作系统和64位应用程序的PC或32位应用程序的32位操作系统。

如何使这个代码更好地工作?

ECHO OFF set isc_user=sysdba set isc_password=masterkey date /t >>tempo.txt time /t >>tempo.txt mode 20,5 del os.txt /q wmic os get osarchitecture >os.txt find "64" os.txt if not errorlevel 1 goto 64b else goto 32b :32b echo off @cmdow @ /DIS mode 84,40 color 80 DEL *.LOG /Q @title 32 LIMPANDO PASTAS ECHO. ECHO ************************* CONFIGURACAO PARA BACKUP EM SISTEMA OPERACIONAL 32 BITS ************************* "C:\Program Files\WinRAR\rar" e auxbkp.rar *.* /y purger.exe -rde 1 c:\ecosis\dados\backup_*.rar purger.exe -rde 5 c:\BKPECO\backup_*.rar ECHO ************************* CONFIGURACAO PARA BACKUP EM SISTEMA OPERACIONAL 32 BITS ************************* CLS attrib +h *.lst attrib +h *.dll attrib +h *.ico attrib +h *.jpg attrib +h *.txt attrib -r auxbkp.rar taskkill -im purger.exe cls @title 32 BACKUP - BANCO DE DADOS - ECO[ ] NFE[ ] SPED[ ] "C:\Program Files\Firebird\Firebird_2_5\bin\gfix.exe" -v -f -z 127.0.0.1:\ecosis\dados\ecodados.eco "C:\Program Files\Firebird\Firebird_2_5\bin\gfix.exe" -v -i 127.0.0.1:\ecosis\dados\ecodados.eco "C:\Program Files\Firebird\Firebird_2_5\bin\gfix.exe" -m -i 127.0.0.1:\ecosis\dados\ecodados.eco "C:\Program Files\Firebird\Firebird_2_5\bin\gfix.exe" -sweep 127.0.0.1:\ecosis\dados\ecodados.eco "C:\Program Files\Firebird\Firebird_2_5\bin\gfix.exe" -rollback all 127.0.0.1:\ecosis\dados\ecodados.eco "C:\Program Files\Firebird\Firebird_2_5\bin\gfix.exe" -m -f -z 127.0.0.1:\ecosis\dados\ecodados.eco "C:\Program Files\Firebird\Firebird_2_5\bin\gbak.exe" -g -b -z -l -v 127.0.0.1:\ecosis\dados\ecodados.eco ecodados_bkp1.gbk -yc:\ecosis\dados\gbk_eco1.log "C:\Program Files\Firebird\Firebird_2_5\bin\gbak.exe" -g -c -v -z -r -rep ecodados_bkp1.gbk ecodados_bkp1.eco -fix_fss_m win1252 -user sysdba -pass masterkey -yc:\ecosis\dados\gbk_eco_restore.log @title 32 BACKUP - BANCO DE DADOS - ECO[ ] NFE[ ] SPED[ ] "C:\Program Files\Firebird\Firebird_2_5\bin\gfix.exe" -v -f -z 127.0.0.1:\ecosis\dados\econfe.eco "C:\Program Files\Firebird\Firebird_2_5\bin\gfix.exe" -v -i 127.0.0.1:\ecosis\dados\econfe.eco "C:\Program Files\Firebird\Firebird_2_5\bin\gfix.exe" -m -i 127.0.0.1:\ecosis\dados\econfe.eco "C:\Program Files\Firebird\Firebird_2_5\bin\gfix.exe" -sweep 127.0.0.1:\ecosis\dados\econfe.eco "C:\Program Files\Firebird\Firebird_2_5\bin\gfix.exe" -rollback all 127.0.0.1:\ecosis\dados\econfe.eco "C:\Program Files\Firebird\Firebird_2_5\bin\gfix.exe" -m -f -z 127.0.0.1:\ecosis\dados\econfe.eco "C:\Program Files\Firebird\Firebird_2_5\bin\gbak.exe" -g -b -z -l -v 127.0.0.1:\ecosis\dados\econfe.eco econfe_bkp1.gbk -yc:\ecosis\dados\gbk_nfe1.log "C:\Program Files\Firebird\Firebird_2_5\bin\gbak.exe" -g -c -v -z -r -rep econfe_bkp1.gbk econfe_bkp1.eco -fix_fss_m win1252 -user sysdba -pass masterkey -yc:\ecosis\dados\gbk_nfe_restore1.log @title 32 BACKUP - BANCO DE DADOS - ECO[ ] NFE[ ] SPED[ ] "C:\Program Files\Firebird\Firebird_2_5\bin\gfix.exe" -v -f -z 127.0.0.1:\ecosis\dados\ecosped.eco "C:\Program Files\Firebird\Firebird_2_5\bin\gfix.exe" -v -i 127.0.0.1:\ecosis\dados\ecosped.eco "C:\Program Files\Firebird\Firebird_2_5\bin\gfix.exe" -m -i 127.0.0.1:\ecosis\dados\ecosped.eco "C:\Program Files\Firebird\Firebird_2_5\bin\gfix.exe" -sweep 127.0.0.1:\ecosis\dados\ecosped.eco "C:\Program Files\Firebird\Firebird_2_5\bin\gfix.exe" -rollback all 127.0.0.1:\ecosis\dados\ecosped.eco "C:\Program Files\Firebird\Firebird_2_5\bin\gfix.exe" -m -f -z 127.0.0.1:\ecosis\dados\ecosped.eco "C:\Program Files\Firebird\Firebird_2_5\bin\gbak.exe" -g -b -z -l -v 127.0.0.1:\ecosis\dados\ecosped.eco ecosped_bkp1.gbk -yc:\ecosis\dados\gbk_sped.log "C:\Program Files\Firebird\Firebird_2_5\bin\gbak.exe" -g -c -v -z -r -rep ecosped_bkp1.gbk ecosped_bkp1.eco -fix_fss_m win1252 -user sysdba -pass masterkey -yc:\ecosis\dados\gbk_sped_restore1.log @title 32 BACKUP - BANCO DE DADOS - ECO[ ] NFE[ ] SPED[ ] "C:\Program Files\WinRAR\rar" u -rr5% -rv15% -ag_dd_mmm_yyyy(hh_mm) -r -m5 -t -dh -x@nao.lst backup.rar @lista.lst "C:\Program Files\WinRAR\rar" u -rr5% -rv15% -ag_yyyy -r -m5 -t -dh -x@nao.lst ecodados.rar @soecogbk.lst cls @title 32 COPIANDO ARQUIVOS ECHO ************************* CONFIGURACAO PARA BACKUP EM SISTEMA OPERACIONAL 32 BITS ************************* XCOPY C:\ECOSIS\DADOS\BACKUP_*.RAR D:\ECOBKPRAR\ /c /r /e /i /d /y purger.exe -rde 7 D:\ECOBKPRAR\BACKUP_*.RAR ECHO ************************* CONFIGURACAO PARA BACKUP EM SISTEMA OPERACIONAL 32 BITS ************************* CLS c:\ecosis\dados\ color 4f @title 32 COMPACTACAO E COPIA DOS BANCO DE DADOS E OUTROS find "errors" gbk*.log if not errorlevel 1 (c:\ecosis\dados\TELEFONE.jpg) else (color 20) find "warning" gbk*.log if not errorlevel 1 (c:\ecosis\dados\TELEFONE.jpg) else (color 20) @title 32 LIMPANDO ARQUIVOS TEMPORARIOS attrib -h *.* taskkill -im purger.exe del c:\ecosis\dados\*.log /q del c:\ecosis\dados\nul*.* /q del C:\ecosis\dados\*_bkp*.ECO /q del c:\ecosis\dados\*.gbk /q del c:\ecosis\dados\*.exe /q del c:\ecosis\dados\*.dll /q del c:\ecosis\dados\*.lst /q del c:\ecosis\dados\*.ico /q del c:\ecosis\dados\*.jpg /q del c:\ecosis\dados\*.txt /q cls @title 32 ENVIANDO ECOGBK FTP ECO @cmdow @ /ENA c:\ecosis\dados\ecoftp.bat exit ECHO ################################################################################################# ECHO ################################################################################################# ECHO ################################################################################################# ECHO ################################################################################################# ECHO ################################################################################################# ECHO ################################################################################################# ECHO ################################################################################################# ECHO ################################################################################################# CLS :64b echo off @cmdow @ /DIS mode 84,40 color 80 set isc_user=sysdba set isc_password=masterkey DEL *.LOG /Q @title 64 LIMPANDO PASTAS "C:\Program Files\WinRAR\rar" e auxbkp.rar *.* /y ECHO. ************************* CONFIGURACAO PARA BACKUP EM SISTEMA OPERACIONAL 64 BITS ************************* purger.exe -rde 1 c:\ecosis\dados\backup_*.rar purger.exe -rde 5 c:\BKPECO\backup_*.rar ECHO. ************************* CONFIGURACAO PARA BACKUP EM SISTEMA OPERACIONAL 64 BITS ************************* CLS attrib +h *.exe attrib +h *.lst attrib +h *.dll attrib +h *.ico attrib +h *.jpg attrib +h *.txt attrib -r auxbkp.rar taskkill -im purger.exe cls @title 64 ECO[ ] NFE[ ] SPED[ ] "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gfix.exe" -v -f -z 127.0.0.1:\ecosis\dados\ecodados.eco "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gfix.exe" -v -i 127.0.0.1:\ecosis\dados\ecodados.eco "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gfix.exe" -m -i 127.0.0.1:\ecosis\dados\ecodados.eco "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gfix.exe" -sweep 127.0.0.1:\ecosis\dados\ecodados.eco "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gfix.exe" -rollback all 127.0.0.1:\ecosis\dados\ecodados.eco "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gfix.exe" -m -f -z 127.0.0.1:\ecosis\dados\ecodados.eco "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gbak.exe" -g -b -z -l -v 127.0.0.1:\ecosis\dados\ecodados.eco ecodados_bkp1.gbk -yc:\ecosis\dados\gbk_eco1.log "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gbak.exe" -g -c -v -z -r -rep ecodados_bkp1.gbk ecodados_bkp1.eco -fix_fss_m win1252 -user sysdba -pass masterkey -yc:\ecosis\dados\gbk_eco_restore.log @title 64 ECO[ ] NFE[ ] SPED[ ] "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gfix.exe" -v -f -z 127.0.0.1:\ecosis\dados\econfe.eco "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gfix.exe" -v -i 127.0.0.1:\ecosis\dados\econfe.eco "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gfix.exe" -m -i 127.0.0.1:\ecosis\dados\econfe.eco "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gfix.exe" -sweep 127.0.0.1:\ecosis\dados\econfe.eco "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gfix.exe" -rollback all 127.0.0.1:\ecosis\dados\econfe.eco "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gfix.exe" -m -f -z 127.0.0.1:\ecosis\dados\econfe.eco "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gbak.exe" -g -b -z -l -v 127.0.0.1:\ecosis\dados\econfe.eco econfe_bkp1.gbk -yc:\ecosis\dados\gbk_nfe1.log "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gbak.exe" -g -c -v -z -r -rep econfe_bkp1.gbk econfe_bkp1.eco -fix_fss_m win1252 -user sysdba -pass masterkey -yc:\ecosis\dados\gbk_nfe_restore1.log @title 64 ECO[ ] NFE[ ] SPED[ ] "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gfix.exe" -v -f -z 127.0.0.1:\ecosis\dados\ecosped.eco "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gfix.exe" -v -i 127.0.0.1:\ecosis\dados\ecosped.eco "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gfix.exe" -m -i 127.0.0.1:\ecosis\dados\ecosped.eco "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gfix.exe" -sweep 127.0.0.1:\ecosis\dados\ecosped.eco "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gfix.exe" -rollback all 127.0.0.1:\ecosis\dados\ecosped.eco "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gfix.exe" -m -f -z 127.0.0.1:\ecosis\dados\ecosped.eco "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gbak.exe" -g -b -z -l -v 127.0.0.1:\ecosis\dados\ecosped.eco ecosped_bkp1.gbk -yc:\ecosis\dados\gbk_sped.log "C:\Arquivos de Programas\firebird\Firebird_2_5\bin\gbak.exe" -g -c -v -z -r -rep ecosped_bkp1.gbk ecosped_bkp1.eco -fix_fss_m win1252 -user sysdba -pass masterkey -yc:\ecosis\dados\gbk_sped_restore1.log @title 64 ECO[ ] NFE[ ] SPED[ ] "C:\Arquivos de Programas\WinRAR\rar" u -rr5% -rv15% -ag_dd_mmm_yyyy(hh_mm) -r -m5 -t -dh -x@nao.lst backup.rar @lista.lst "C:\Arquivos de Programas\WinRAR\rar" u -rr5% -rv15% -ag_yyyy -r -m5 -t -dh -x@nao.lst ecodados.rar @soecogbk.lst cls @title 64 COPIANDO ARQUIVOS ECHO. ************************* CONFIGURACAO PARA BACKUP EM SISTEMA OPERACIONAL 64 BITS ************************* XCOPY C:\ECOSIS\DADOS\BACKUP_*.RAR D:\ECOBKPRAR\ /c /r /e /i /d /y purger.exe -rde 7 D:\ECOBKPRAR\BACKUP_*.RAR ECHO. ************************* CONFIGURACAO PARA BACKUP EM SISTEMA OPERACIONAL 64 BITS ************************* CLS c:\ecosis\dados\ color 4f @title 64BACKUP FINALIZADO find "errors" gbk*.log if not errorlevel 1 (c:\ecosis\dados\TELEFONE.jpg) else (color 20) find "warning" gbk*.log if not errorlevel 1 (c:\ecosis\dados\TELEFONE.jpg) else (color 20) @title 64 LIMPANDO ARQUIVOS TEMPORARIOS attrib -h *.* taskkill -im purger.exe del c:\ecosis\dados\*.log /q del c:\ecosis\dados\nul*.* /q del C:\ecosis\dados\*_bkp*.ECO /q del c:\ecosis\dados\*.gbk /q del c:\ecosis\dados\*.exe /q del c:\ecosis\dados\*.dll /q del c:\ecosis\dados\*.lst /q del c:\ecosis\dados\*.ico /q del c:\ecosis\dados\*.jpg /q del c:\ecosis\dados\*.txt /q cls date /t >>tempo.txt time /t >>tempo.txt echo ** ** ** ECOBACKUP** ** ** >>tempo.txt @title 64 ENVIANDO ECOGBK FTP ECO @cmdow @ /ENA c:\ecosis\dados\ecoftp.bat exit 

像这些片段应该做的伎俩:

 REM Find the gfix.exe executable C: cd \ set GFX_PGMFNM= for /R %%F in (gfix.exe) do set GFX_PGMFNM=%%~dpnxF if "%GFX_PGMFNM%" == "" goto NOGFX REM Then later: "%GFX_PGMFNM%" -v -f -z 127.0.0.1:\ecosis\dados\ecosped.eco goto ENDIT REM Exit messages :NOGFX echo. echo ERROR: Cannot find gfix.exe on the C: drive echo. goto ENDIT REM Cleanup :ENDIT set GFX_PGMFNM= 

使用您的WMI查询操作系统体系结构,并根据结果创建一个新的程序文件变量。

然后使用%ProgFiles%变量而不是硬编码路径C:\Program Files\C:\Arquivos de Programas

这应该做的伎俩:

 wmic os get osarchitecture |find /i "64" > NUL IF %ERRORLEVEL%==0 ( Echo 64Bit OS detected set ProgFiles="%ProgramFiles(x86)%" ) ELSE ( Echo 32Bit OS detected set ProgFiles="%ProgramFiles%" ) echo %ProgFiles% 

Windows中有一个名为ProgramFiles的环境变量。 有没有理由不能使用这个变量? 对于安装了一些32位应用程序的64位环境,还有可变的ProgramFiles(x86)