如何选择"程序文件"你有很多具有32位和64位操作系统以及32或64位应用程序的PC的文件夹吗?
我创建了一个文件来创建firebird数据库的备份,但我需要帮助。有时候有一台带有64位操作系统和32位firebird或winrar的PC。有时会有一台配备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 -y c:\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 -y c:\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 -y c:\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 -y c:\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 -y c:\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 -y c:\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 -y c:\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 -y c:\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 -y c:\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 -y c:\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 -y c:\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 -y c:\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
答案 0 :(得分:1)
像这些片段之类的东西可以解决这个问题:
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=
答案 1 :(得分:1)
将您的WMI查询用于OS体系结构,并根据结果为Programfiles创建一个新的变量。
然后使用%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%
答案 2 :(得分:1)
Windows中已存在一个名为ProgramFiles
的环境变量。你有什么理由不能使用那个变量吗?对于安装了一些32位应用程序的64位环境,还有变量ProgramFiles(x86)
。