I am attempting to check if machines in a list have Outlook 2010 standalone installed using a batch file, I can run the script if I hard code each check but I am after something that pulls from a file, this is what I have so far:
Important Info:
I am wanting to run this via a batch file, machines can be a mix of windows 7 and XP and it needs to be able to tell the difference between Office 2010 with Outlook and Outlook Standalone
@echo off
setlocal enabledelayedexpansion
set INPUT_FILE=%1
set UP_OUTPUT_FILE=yes.txt
set DN_OUTPUT_FILE=no.txt
echo These Machines have Outlook 2010: >> %UP_OUTPUT_FILE%
echo These Machines don't have Outlook 2010: >> %DN_OUTPUT_FILE%
for /f %%i in (%INPUT_FILE%) do (
reg query \\%%i\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{90140000-001A-0000-0000-0000000FF1CE} > NUL
if errorlevel 1 goto error1
if errorlevel 0 goto error0
:error1
echo %%i >> %DN_OUTPUT_FILE%
goto next1
:error0
echo %%i >> %UP_OUTPUT_FILE%
:next1
)
The problem I am having is it keeps returning an error:
) was unexpected at this time.
If I remove the )
it breaks the script completly and it won't run, if I move it it cuts the loop early.
for /f %%i in (%INPUT_FILE%) do (
reg query \\%%i\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{90140000-001A-0000-0000-0000000FF1CE} > NUL
if errorlevel 1 (
echo %%i >> %DN_OUTPUT_FILE%
) else (
echo %%i >> %UP_OUTPUT_FILE%
)
)
Whenever a goto
command is executed inside a for
loop, the looping is cancelled.