用于检测 32 位与 64 位办公室不工作的批处理文件代码 [英] batch file code to detect 32-bit vs 64-bit office not working

查看:17
本文介绍了用于检测 32 位与 64 位办公室不工作的批处理文件代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一个批处理文件放在一起,以便在用户运行时选择合适的可执行文件位版本.我在stackoverflow上找到了这段代码:批量文件检查办公架构版本问题是当我将其粘贴到桌面上的文本文件中并在安装了 64 位 Office 2010 的虚拟机中将其重命名为 .bat 时它不起作用:它声称它是 32 位,默认值设置在编码.不擅长检查注册表项,我想知道是否在某个地方没有现成的版本可以实际工作.我也想知道为什么没有一种简单的方法来确定这一点.我原以为这是微软可以让开发人员轻松访问的东西.

I'm trying to put together a batch file that would select the appropriate bit version of executables when run by the user. I found this code on stackoverflow: Batch file check office architecture version The problem is that it does not work when I paste it into a text file on my desktop and rename it .bat in my virtual machine that has 64-bit Office 2010 installed: it claims it is 32-bit, the default value set in the code. Not being adept in checking registry entries, I'm wondering if there isn't a ready-made version out there somewhere that actually works. I'm also wondering why there isn't a simple way to determine this. I would have thought that this is something that Microsoft would make easily accessible to developers.

推荐答案

如果你想检查 Microsoft Office 的位数、版本和安装位置,你可以给这个脚本一个测试,看看它是否适合你更好:

If you're wanting to check the bitness, version and install location of Microsoft Office, you could give this script a test to see if it works for you any better:

@Echo Off
If Defined PROCESSOR_ARCHITEW6432 (
    Start "" /D "%__CD__%" "%SystemRoot%SysNativecmd.exe" /C "%~f0"&Exit /B)
Set /A "OSA=MWB=%PROCESSOR_ARCHITECTURE:~-2%"
If %OSA%==86 Set "MWB=32"
Set "MOB="&Set "GUID="&Set "REG=%__AppDir__%reg.exe"
Call :Chk
If Not Defined MOB If %MWB%==64 Call :Chk Wow6432Node
If Not Defined MOB (Echo Microsoft Office product not installed&GoTo :EndIt
)Else If Not Defined IOV (Echo Unable to determine Microsoft Office version
    GoTo :EndIt)
Echo %MWB%-bit OS with an Office 20%IOV% %MOB%-bit product installed in %OIL%
:EndIt
>Nul Timeout -1
GoTo :EOF

:Chk
Set "MOB="&Set "GUID="&Set "OIL="
Set "Key=HKLMSoftware%1MicrosoftWindowsCurrentVersionUninstall"
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"
If "%GUID:~4,1%"=="2" Set "IOV=07"
If "%GUID:~4,1%"=="4" Set "IOV=10"
If "%GUID:~4,1%"=="5" Set "IOV=13"
If "%GUID:~4,1%"=="6" Set "IOV=16"
If Not Defined IOV Exit /B
For /F Tokens^=2* %%A In ('""%REG%" Query "%Key%\%GUID%" /V "InstallLocation""'
)Do Set "OIL=%%B"
Exit /B

但是请注意,此脚本旨在与从 20072016 版本(含)的 Windows Microsoft Office 产品一起使用.该脚本仅检查 Microsoft Word 的特定卸载密钥,(假设只有在极少数情况下有人会安装 Office 而不包含 Word 产品),并且不能保证所有版本都将使用相同的卸载密钥.

Please note however, that this script was designed to work with Windows Microsoft Office products from versions 2007 up to 2016 inclusive. The script only checks for a specific uninstall key for Microsoft Word, (it is assumed that only in very rare cases would somebody install Office without including the Word product), and there is no guarantee that all versions will use the same uninstall key.

我不会修改此代码以对您的问题进行任何添加/更改,也不会为非预期目的的修改提供帮助.

这篇关于用于检测 32 位与 64 位办公室不工作的批处理文件代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆