我想创建一个批处理文件,该文件将检查用户环境中是否有MSOffice安装类型(32位或64位),然后复制特定于该环境的文件。我从这段代码开始,获取版本
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 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
来自Batch file check office architecture version,但想要进一步扩展它以便复制。 我正在尝试
If "MOB=32" copy /y "\\file(32-Bit).exe" c:\%USERPROFILE%\Desktop
Else copy /y "\\file(64-Bit).exe" c:\%USERPROFILE%\Desktop
Echo=&Echo= Copy Completed! Have A Nice Day!
但是此时仍然没有预期复制",也尝试使用xcopy并得到相同的结果。这对于在混合环境中部署,任何想法都有帮助吗?非常确定语法错误=(
答案 0 :(得分:0)
If %MOB%==32 (copy /y "\\file(32-Bit).exe" c:\%USERPROFILE%\Desktop
) Else (copy /y "\\file(64-Bit).exe" c:\%USERPROFILE%\Desktop)
IF
真实条件目标if
else
关键字必须位于同一物理行else
关键字,分隔符和"其他"的左括号。 block必须在同一条物理线上即
if condition (
something
) else (
someotherthing
)