Compare Registry Values (VBS)

Purpose: You have two registry values, which you need to compare

This solution is not compatible as a SCCM application custom script detection method. It is meant to generally demonstrate how to compare registry values with VBS.

Usage: cscript.exe IT_OSD_VBS_CompareTwoRegistryValues.vbs (no parameters exist)
Configuration: You need to insert your own registry paths.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
' *********************************************************************************
' ** Script Name: IT_OSD_VBS_CompareTwoRegistryValues.vbs
' ** Created on: 17.06.2013
' ** Author: Jyri Lehtonen / http://it.peikkoluola.net
' **
' ** Purpose: You have two registry values, which you need to compare
' ** Usage: IT_OSD_VBS_CompareTwoRegistryValues.vbs (no parameters exist)
' **
' ** License: This program is free software: you can redistribute it and/or modify
' ** it under the terms of the GNU General Public License as published by
' ** the Free Software Foundation, either version 3 of the License, or
' ** (at your option) any later version.
' **
' ** This program is distributed in the hope that it will be useful,
' ** but WITHOUT ANY WARRANTY; without even the implied warranty of
' ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' ** GNU General Public License for more details.
' ** 
' ** History: 
' ** 1.0 / Jyri Lehtonen / 17.06.2013 / Initial version.
' *********************************************************************************
 
Dim WSHShell, value
On Error Resume Next
 
Compare_Value_1="insert value"
Compare_Value_2="insert value"
 
Set WSHShell = CreateObject("WScript.Shell")
Registry_Value_1 = WSHShell.RegRead( Compare_Value_1 )
Registry_Value_2 = WSHShell.RegRead( Compare_Value_2 )
 
If Registry_Value_1 = Registry_Value_2 Then
    WScript.Quit 0
Else
    WScript.Quit 1
End if
' *********************************************************************************
' ** Script Name: IT_OSD_VBS_CompareTwoRegistryValues.vbs
' ** Created on: 17.06.2013
' ** Author: Jyri Lehtonen / http://it.peikkoluola.net
' **
' ** Purpose: You have two registry values, which you need to compare
' ** Usage: IT_OSD_VBS_CompareTwoRegistryValues.vbs (no parameters exist)
' **
' ** License: This program is free software: you can redistribute it and/or modify
' ** it under the terms of the GNU General Public License as published by
' ** the Free Software Foundation, either version 3 of the License, or
' ** (at your option) any later version.
' **
' ** This program is distributed in the hope that it will be useful,
' ** but WITHOUT ANY WARRANTY; without even the implied warranty of
' ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' ** GNU General Public License for more details.
' ** 
' ** History: 
' ** 1.0 / Jyri Lehtonen / 17.06.2013 / Initial version.
' *********************************************************************************

Dim WSHShell, value
On Error Resume Next

Compare_Value_1="insert value"
Compare_Value_2="insert value"

Set WSHShell = CreateObject("WScript.Shell")
Registry_Value_1 = WSHShell.RegRead( Compare_Value_1 )
Registry_Value_2 = WSHShell.RegRead( Compare_Value_2 )

If Registry_Value_1 = Registry_Value_2 Then
	WScript.Quit 0
Else
	WScript.Quit 1
End if

Leave a Reply

Your email address will not be published. Required fields are marked *


+ two = eight

Post Navigation