【发布时间】:2019-03-31 09:02:26
【问题描述】:
在检查了正确的处理器类型后,我尝试了两种不同的脚本来安装可执行文件。我相信可执行文件会运行,但由于某种原因,它无法检查文件是否已经存在。我会在这里发布。
有人可以帮忙吗?
@echo on
if /i "%processor_architecture%"=="x86" (
if exist "C:\Program Files\Credential Wizard\CredentialWizard.exe" (
echo ***App is Installed Successfully***
) else (\\srvfs01.flymyrtlebeach.com\deployment$\Software\Nervepoint\nam-creds-provider-windows-x86-2.0.4.exe -q)
) else if /i "%processor_architecture%"=="X64" (
if exist "C:\Program Files (x86)\Credential Wizard\CredentialWizard.exe" (
echo ***App is Installed Successfully***
) else (\\srvfs01.flymyrtlebeach.com\deployment$\Software\Nervepoint\nam-creds-provider-windows-x64-2.0.4.exe -q)
)
exit
或者这个
@echo off
Set RegQry=HKLM\Hardware\Description\System\CentralProcessor\0
REG.exe Query %RegQry% | Find /i "x86"
If %ERRORLEVEL% == 0 (
GOTO X86
) ELSE (
GOTO X64
)
:X86
IF NOT EXIST "C:\Program Files\Credential Wizard\CredentialWizard.exe"(start \\srvfs01.flymyrtlebeach.com\deployment$\Software\Nervepoint\nam-creds-provider-windows-x86-2.0.4.exe -q)
GOTO END
:X64
IF NOT EXIST "C:\Program Files (x86)\Credential Wizard\CredentialWizard.exe"(start \\srvfs01.flymyrtlebeach.com\deployment$\Software\Nervepoint\nam-creds-provider-windows-x64-2.0.4.exe -q)
:End
exit
【问题讨论】:
-
你的想法是错误的,在64位操作系统上,64位程序会被安装到
%ProgramFiles%,在32位操作系统上,32位程序会被安装到%ProgramFiles%。%ProgamFiles(x86)%,应该是 64 位操作系统上的 32 位版本,如果您的系统使用正确的操作系统位软件,您只需要检查%ProgramFiles%。 -
您是否调试过您的脚本以确定它是否正确 无法查看文件与不正确 是否无法查看文件?换句话说,你是说文件在那里而这段代码看不到它吗?或者您是说该文件实际上不是您的脚本期望找到的位置?
标签: batch-file installation file-exists not-exists