Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.touchpoint.natives/nativePackageScripts/windows/isInstalled.bat')
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/nativePackageScripts/windows/isInstalled.bat40
1 files changed, 40 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/nativePackageScripts/windows/isInstalled.bat b/bundles/org.eclipse.equinox.p2.touchpoint.natives/nativePackageScripts/windows/isInstalled.bat
new file mode 100644
index 000000000..feaf81541
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/nativePackageScripts/windows/isInstalled.bat
@@ -0,0 +1,40 @@
+:: Check if a registry key and, optionally, an attribute is available in the registry.
+:: Return 0 if the key/attribute is installed, 2 otherwise.
+:: Usage
+:: isInstalled.bat key [attributeName attributeValue]
+
+@echo off
+SetLocal EnableExtensions
+
+Set key=%1
+
+:: if no attribute name is supplied, only check the key
+If "%2"=="" Goto check_key
+
+
+
+:check_attribute
+Set attribute=%2
+Set value=%3
+
+:: query registry and get the second and third token, which is the type and the value
+For /F "usebackq tokens=2,3" %%A In (`reg query "%key%" /v "%attribute%" 2^>nul ^| find "%attribute%"`) Do (
+ Set type=%%A
+ Set value_actual=%%B
+)
+
+If "REG_DWORD"=="%type%" (
+ :: convert hex to int value
+ Set /A value_actual=%value_actual%
+)
+
+If Not %value_actual% Equ %value% exit /B 2
+exit /B 0
+
+
+
+:check_key
+reg query "%key%" >nul 2>nul
+If Errorlevel 1 exit /B 2
+
+exit /B 0

Back to the top