我有某人为我编写的install.bat文件。它需要在客户端上基于MSOffice的位数安装应用程序。它还需要根据Windows的位数运行SQL客户端驱动程序安装文件。
SQL部分工作正常。但是,当我确实安装了64位办公软件时(它已经在两台都安装了64位办公软件的计算机上进行了测试),它将不断安装该应用程序的32位版本而不是64位。我确信,专家可以浏览代码并快速告诉我问题出在哪里。这不是我的专业领域,但我知道这并不复杂。在安装文件夹中,有一个名为Source32和Source64的文件夹。 Source32中的两个32bit应用程序和Source64文件夹中的两个64bit应用程序。它从相关的文件夹中提取这些文件,并将它们放入根目录(C:\ QuickSuite)中创建的文件夹中。我对正在查看的内容只有一个很模糊的想法,所以我什至不确定要尝试什么。
@Echo off&SetLocal
Set "KEY="&Set "GUID="&Set "IOV="&Set "MWB=32"&Set "MOB=32"
Echo=%PROCESSOR_ARCHITECTURE% %PROCESSOR_ARCHITEW6432%|Find "64">Nul&&(
Set "KEY=\Wow6432Node"&Set "MWB=64")
Set "KEY=HKLM\Software%KEY%\Microsoft\Windows\CurrentVersion\Uninstall"
For /f "Delims=" %%a In ('Reg Query %KEY% /k /f "*-001B-*0FF1CE}"') Do (
If Not Defined GUID Set "GUID=%%~nxa")
If Not Defined GUID (Echo=Unable to find Office Product&GoTo :EndIt)
If %GUID:~20,1% Equ 1 Set "MOB=64"
If %GUID:~4,1% Equ 4 (Set IOV=10) Else (If %GUID:~4,1% Equ 6 (Set IOV=16) Else (If %GUID:~4,1% Equ 2 (Set IOV=07) Else (
If %GUID:~4,1% Equ 5 (Set IOV=13) Else (Set IOV=??))))
Echo=&Echo= Office 20%IOV% %MOB%-bit Product installed on a %MWB%-bit OS
If %MWB% == 64 (
@Echo Windows 64-bit...
msiexec /i "%~dp0sql64\sqlncli_x64.msi" IACCEPTSQLNCLILICENSETERMS=YES /qb
)
If %MWB% == 32 (
@Echo Windows 32-bit...
msiexec /i "%~dp0sql32\sqlncli_x86.msi" IACCEPTSQLNCLILICENSETERMS=YES /qb
)
cd %~dp0
SET _source64=.\Source64
SET _source32=.\Source32
SET _dest=%systemdrive%\QuickSuite
SET _FrontOffice=.\FrontOffice
SET _RemoteSMS=.\RemoteSMS
SET _dest_RemoteSMS=%systemdrive%\QuickSuite\RemoteSMS
SET _dest_FrontOffice=%systemdrive%\QuickSuite\FrontOffice
If %MOB% == 64 (
@echo Microsoft Office is 64-bit
robocopy %_source64% %_dest% /E
robocopy %_FrontOffice% %_dest_FrontOffice% /E
robocopy %_RemoteSMS% %_dest_RemoteSMS% /E
)
If %MOB% == 32 (
@echo Microsoft Office is 32-bit
robocopy %_source32% %_dest% /E
robocopy %_FrontOffice% %_dest_FrontOffice% /E
robocopy %_RemoteSMS% %_dest_RemoteSMS% /E
)
:EndIt
TimeOut /t 5 1>Nul
答案 0 :(得分:0)
以下是一个基于您提供的代码以及我想尝试使用的示例:
@Echo Off
If Defined PROCESSOR_ARCHITEW6432 (
Start "" /D "%__CD__%" "%SystemRoot%\SysNative\cmd.exe" /C "%~f0"&Exit /B)
Set /A "OSA=MWB=%PROCESSOR_ARCHITECTURE:~-2%"
If %OSA%==86 Set "MWB=32"
For %%A In (MSIExec Reg RoboCopy)Do Set "%%A=%__AppDir__%%%A.exe"
Echo Windows %MWB%-bit...
"%MSIExec%" /i "%~dp0sql%MWB%\sqlncli_x%OSA%.msi" IACCEPTSQLNCLILICENSETERMS=YES /qb
Call :Chk
If Not Defined MOB If %OSA%==64 Call :Chk \Wow6432Node
If Not Defined MOB (Echo Office Product not installed&GoTo :EndIt)
Echo Microsoft Office %MOB%-bit Product is installed
"%RoboCopy%" "%~dp0Source%MWB%" "%SystemDrive%\QuickSuite" /E
"%RoboCopy%" "%~dp0FrontOffice" "%SystemDrive%\QuickSuite\FrontOffice" /E
"%RoboCopy%" "%~dp0RemoteSMS" "%SystemDrive%\QuickSuite\RemoteSMS" /E
:Endit
Timeout 5 /NoBreak>Nul
GoTo :EOF
:Chk
Set "MOB="&Set "GUID="
Set "Key=HKLM\Software%1\Microsoft\Windows\CurrentVersion\Uninstall"
For /F Delims^= %%A In ('""%REG%" Query "%Key%" /K /F "*-001B-*0FF1CE}""'
)Do Set "GUID=%%~nxA"&GoTo :Next
:Next
If Not "%GUID:~-1%"=="}" Set "GUID="
If Not Defined GUID Exit /B
Set "MOB=32"&If "%GUID:~20,1%"=="1" Set "MOB=64"
Exit /B