I have this script but for some reason I keep getting issues. One of the issues was something about the syntax being incorrect. I re-ran it and the issue is different but it says "N was unexpected at this time" then it has the line "if EQU N (" where it broke.
Here is the script:
SET LOG_FILE="D:\SmCpm\ElektronTMS\%PCN_NUM%_RollbackLog.txt"
SET UNINSTALL5012=N
SET UNINSTALL5013=N
SET UNINSTALL5014=N
SET UNINSTALL5015=N
SET UNINSTALL5017=N
SET UNINSTALL5018=N
SET UNINSTALLV131=N
SET UNINSTALLV140=N
SET UNINSTALLV141=N
SET INST=""
SET ETMSFILENAME="ElektronTMS.msi"
:: *******************************************
:: Stop the SMF Service.
ECHO Rolling back installation of %PCN_NUM%
net stop smf
ping 127.0.0.1 -n 5 > nul
:: *******************************************
:: determine which PCNs need to be uninstalled.
FOR /F "tokens=2*" %%A IN ('REG QUERY "HKLM\SOFTWARE\Wow6432Node\Reuters\TMS" /v PCN5021') DO (
set INST=%%B
)
if not x%INST:5012=%==x%INST% (
SET UNINSTALL5012=Y
)
if not x%INST:5013=%==x%INST% (
SET UNINSTALL5013=Y
)
if not x%INST:5014=%==x%INST% (
SET UNINSTALL5014=Y
)
if not x%INST:5015=%==x%INST% (
SET UNINSTALL5015=Y
)
if not x%INST:5017=%==x%INST% (
SET UNINSTALL5017=Y
)
if not x%INST:5018=%==x%INST% (
SET UNINSTALL5018=Y
)
if not x%INST:V131=%==x%INST% (
SET UNINSTALLV131=Y
)
if not x%INST:V140=%==x%INST% (
SET UNINSTALLV140=Y
)
if not x%INST:V141=%==x%INST% (
SET UNINSTALLV141=Y
)
:: ***********************
:: Uninstall the packages.
ECHO Rolling back patch
IF %UNINSTALLV131% EQU Y (
FOR /F "tokens=3*" %%C IN ('c:\windows\system32\reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\48AB8A7CAE88C33488B5F1498871520C\InstallProperties /v LocalPackage') DO (
SET LOCALPACKAGE=%%C
)
FOR /F "tokens=3*" %%S IN ('c:\windows\system32\reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\48AB8A7CAE88C33488B5F1498871520C\InstallProperties /v InstallSource') DO (
SET SOURCEINSTALL=%%S
)
if not exist %SOURCEINSTALL% (
md "%SOURCEINSTALL%"
SET SOURCEEXISTS=N
)
if exist %SOURCEINSTALL% (
SET SOURCEEXISTS=Y
)
SET COPYTODIR=%SOURCEINSTALL%%ETMSFILENAME%
copy /y %LOCALPACKAGE% %COPYTODIR%
msiexec -package {C7A8BA84-88EA-433C-885B-1F94881725C0} -uninstall {F732939E-ED57-43FC-B298-83F933E1F950} -quiet -norestart -lv+ %LOG_FILE%
ping 127.0.0.1 -n 5 > nul
if %SOURCEEXISTS% EQU N (
rd /s /q "%SOURCEINSTALL%"
) else (
del /F %COPYTODIR%
)
)
IF %UNINSTALLV140% EQU Y (
FOR /F "tokens=3*" %%C IN ('c:\windows\system32\reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\98AF25D0FB734FC4BA465843970476B6\InstallProperties /v LocalPackage') DO (
SET LOCALPACKAGE=%%C
)
FOR /F "tokens=3*" %%S IN ('c:\windows\system32\reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\98AF25D0FB734FC4BA465843970476B6\InstallProperties /v InstallSource') DO (
SET SOURCEINSTALL=%%S
)
if not exist %SOURCEINSTALL% (
md "%SOURCEINSTALL%"
SET SOURCEEXISTS=N
)
if exist %SOURCEINSTALL% (
SET SOURCEEXISTS=Y
)
SET COPYTODIR=%SOURCEINSTALL%%ETMSFILENAME%
copy /y %LOCALPACKAGE% %COPYTODIR%
msiexec -package {0D52FA89-37BF-4CF4-AB64-85347940676B} -uninstall {C845F8AE-6935-42D9-AE8C-2564E2A82C71} -quiet -norestart -lv+ %LOG_FILE%
ping 127.0.0.1 -n 5 > nul
if %SOURCEEXISTS% EQU N (
rd /s /q "%SOURCEINSTALL%"
) else (
del /F %COPYTODIR%
)
)
IF %UNINSTALLV141% EQU Y (
FOR /F "tokens=3*" %%C IN ('c:\windows\system32\reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\DFFF30F7568D1D144B5B7B785F32638D\InstallProperties /v LocalPackage') DO (
SET LOCALPACKAGE=%%C
)
echo %LOCALPACKAGE%
FOR /F "tokens=3*" %%S IN ('c:\windows\system32\reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\DFFF30F7568D1D144B5B7B785F32638D\InstallProperties /v InstallSource') DO (
SET SOURCEINSTALL=%%S
)
if not exist %SOURCEINSTALL% (
md "%SOURCEINSTALL%"
SET SOURCEEXISTS=N
)
if exist %SOURCEINSTALL% (
SET SOURCEEXISTS=Y
)
SET COPYTODIR=%SOURCEINSTALL%%ETMSFILENAME%
copy /y %LOCALPACKAGE% %COPYTODIR%
msiexec -package {7F03FFFD-D865-41D1-B4B5-B787F52336D8} -uninstall {464FBA62-6FA9-4744-BDA7-68284B61B6DB} -quiet -norestart -lv+ %LOG_FILE%
ping 127.0.0.1 -n 5 > nul
if %SOURCEEXISTS% EQU Y (
rd /s /q "%SOURCEINSTALL%"
) else (
del /F %COPYTODIR%
)
)
I have queried all registry value details and i can see that there is a source install value and a local package value as well. At first it complained about the syntax error being with my "if not exist" but now i get another error and i don't know what is wrong with my batch!
Can someone help?
Thanks