批处理脚本,用于检查注册表项中的Office版本并创建新的Outlook配置文件



我有 100 台具有不同 Office 版本的 PC,我想使用 GPO 为所有这台 PC 的用户创建新的 Outlook 配置文件。所以我需要一个批处理脚本,它将检查注册表项中的Office版本(可能带有reg查询HKEY_CLASSES_ROOTWord.ApplicationCurVer),然后创建一个新的注册表项。
例:

reg add "HKCUSoftwareMicrosoftOffice16.0OutlookProfilesNewProfile"
reg add "HKCUSoftwareMicrosoftOffice16.0Outlook" /v DefaultProfile /t REG_SZ /d "NewProfile" /F

我试过这个:

@Echo
reg query "HKEY_CLASSES_ROOTWord.ApplicationCurVer" "(Default)" | Find "Word.Application.16" IF %ERRORLEVEL% EQU 1 goto first IF %ERRORLEVEL% EQU 0 goto second goto end
:second
reg add "HKCUSoftwareMicrosoftOffice16.0OutlookProfilesNewProfile"
reg add "HKCUSoftwareMicrosoftOffice16.0Outlook" /v DefaultProfile /t REG_SZ /d "NewProfile" /F
goto end
:first
goto end
:end
@exit

但它给出了一个错误:

错误:语法无效。键入"REG QUERY/?" 进行用法。

也许有人知道问题出在哪里?

尝试如下:

@Echo
reg query "HKEY_CLASSES_ROOTWord.ApplicationCurVer" | (
    Find "Word.Application.16"  >nul 2>&1 ) && (
        goto :second
    ) || (
        goto :first
    )
:second
reg add "HKCUSoftwareMicrosoftOffice16.0OutlookProfilesNewProfile"
reg add "HKCUSoftwareMicrosoftOffice16.0Outlook" /v DefaultProfile /t REG_SZ /d "NewProfile" /F
goto :end
:first
goto end
:end
@exit

最新更新