# =0 was unexpected at this time Batch Script woes



## 1234Mike (Aug 24, 2012)

Hello, I could really use some help getting a script right. All I'm trying to do is check for the presence of a registry and perform or not perform an action depending on the result. It works the first time but subsequent runs fail with =0 was unexpected at this time. HELP!



rem ECHO on
rem CLS
setlocal enableextensions EnableDelayedExpansion

::Uninstall THUNDERBIRD x64 SOME Versions
:REMOVETHUNDERBIRDX64
Reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Mozilla Thunderbird (3.1.20)" /v "DisplayVersion"
IF %Errorlevel%=0 'C:\Program Files\Mozilla Thunderbird\uninstall\helper.exe' (
) ELSE (
IF %%Errorlevel=1 echo not found here
Echo Errorlevel=%%Errorlevel
goto pause
)
:EXIT
EXIT


----------



## Squashman (Apr 4, 2003)

Reg Query will always return a 0 or 1 so knowing that information you really don't even need to check the errorlevels. You can use conditional processing instead.

```
::Uninstall THUNDERBIRD x64 SOME Versions
:REMOVETHUNDERBIRDX64
2>nul reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Mozilla Thunderbird (3.1.20)" /v "DisplayVersion" &&(
	"C:\Program Files\Mozilla Thunderbird\uninstall\helper.exe"
) || (
	echo not found here
)

EXIT
```


----------

