I have 100 PC's with different Office versions and I want to create a new Outlook profiles for all this PC's users with GPO. So I need a batch script which will check Office version in registry key's (maybe with reg query HKEY_CLASSES_ROOT\Word.Application\CurVer
) and then creates a new registry entry.
Example:
reg add "HKCU\Software\Microsoft\Office\16.0\Outlook\Profiles\NewProfile"
reg add "HKCU\Software\Microsoft\Office\16.0\Outlook" /v DefaultProfile /t REG_SZ /d "NewProfile" /F
I tried this:
@Echo
reg query "HKEY_CLASSES_ROOT\Word.Application\CurVer" "(Default)" | Find "Word.Application.16" IF %ERRORLEVEL% EQU 1 goto first IF %ERRORLEVEL% EQU 0 goto second goto end
:second
reg add "HKCU\Software\Microsoft\Office\16.0\Outlook\Profiles\NewProfile"
reg add "HKCU\Software\Microsoft\Office\16.0\Outlook" /v DefaultProfile /t REG_SZ /d "NewProfile" /F
goto end
:first
goto end
:end
@exit
But It gives an error:
ERROR: Invalid syntax. Type "REG QUERY /?" for usage.
Maybe someone knows where is the problem?
try like this:
@Echo
reg query "HKEY_CLASSES_ROOT\Word.Application\CurVer" | (
Find "Word.Application.16" >nul 2>&1 ) && (
goto :second
) || (
goto :first
)
:second
reg add "HKCU\Software\Microsoft\Office\16.0\Outlook\Profiles\NewProfile"
reg add "HKCU\Software\Microsoft\Office\16.0\Outlook" /v DefaultProfile /t REG_SZ /d "NewProfile" /F
goto :end
:first
goto end
:end
@exit