Support Forums

help combining 2 scripts

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.
User avatar
jjimenez
Posts: 12
Joined: Sun Mar 02, 2014 12:28 pm

help combining 2 scripts

Postby jjimenez » Wed Mar 05, 2014 1:24 pm

I'd like the following script to only put out one result. Either the 64bit app is compliant/non compliant/ or not installed or the 32 bit section is such.
VBScript Code
Double-click the code block to select all.
const HKEY_LOCAL_MACHINE  = &H80000002
on error resume next
Dim dversion, GUIDid

dversion = "6.1.20913.0"
GUIDid = "{89F4137D-6C26-4A84-BDB8-2E5A4BB71E00}"

set oWsh = createobject("wscript.shell")
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")


strKeyPath = "software\microsoft\windows\currentversion\uninstall"
sDisplayVersion = oWsh.Regread("HKLM\" & strKeyPath & "\" & GUIDid & "\DisplayVersion")
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue

if err.number <>0 then
wscript.echo "Not-Installed"
err.clear
else

If Eval("sDisplayVersion >= dversion") Then
wscript.echo "Compliant"

Elseif Eval("sDisplayVersion < dversion") Then
wscript.echo sDisplayVersion

End if
End if



strKeyPath = "software\wow6432node\microsoft\windows\currentversion\uninstall"
sDisplayVersion = oWsh.Regread("HKLM\" & strKeyPath & "\" & GUIDid & "\DisplayVersion")
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue

if err.number <>0 then
wscript.echo "Not-Installed"
err.clear
else

If Eval("sDisplayVersion >= dversion") Then
wscript.echo "Compliant"

Elseif Eval("sDisplayVersion < dversion") Then
wscript.echo sDisplayVersion

End if
End if


it does both right now, please help me seperate them.
User avatar
jvierra
Posts: 10030
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: help combining 2 scripts

Postby jvierra » Wed Mar 05, 2014 1:35 pm

Sorry but I cannot make sense out of what you are trying to do with you script. It doesn't make much sense.

Did you copy this from somewhere?
User avatar
jvierra
Posts: 10030
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: help combining 2 scripts

Postby jvierra » Wed Mar 05, 2014 1:38 pm

Note that for WMI you need to pick the architecture in advance.

You cannot directly compare strings unless you are sure they are identically formatted.

"1.2.3.4" > "1.2.14.5"


will likely fail.
User avatar
jjimenez
Posts: 12
Joined: Sun Mar 02, 2014 12:28 pm

Re: help combining 2 scripts

Postby jjimenez » Wed Mar 05, 2014 1:43 pm

the script works fine.

what i'm trying to do is search one string and if that exists then return a value,

if not then search a different string and if that exists then return a value

if neither exist then error
User avatar
jvierra
Posts: 10030
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: help combining 2 scripts

Postby jvierra » Wed Mar 05, 2014 1:52 pm

This is as close as you will get:

VBScript Code
Double-click the code block to select all.
const HKEY_LOCAL_MACHINE  = &H80000002

dversion = "6.1.20913.0"
GUIDid = "{89F4137D-6C26-4A84-BDB8-2E5A4BB71E00}"
set oWsh = createobject("wscript.shell")

On Error Resume Next
strKeyPath = "software\microsoft\windows\currentversion\uninstall"
sDisplayVersion = oWsh.Regread("HKLM\" & strKeyPath & "\" & GUIDid & "\DisplayVersion")
if err.number <>0 Then
wscript.echo "Not-Installed in 32 bit registry"
Else
if(sDisplayVersion >= dVersion) Then
WScript.Echo "Up to date:" & sDisplayVersion
Else
WScript.Echo "Not up to date:" & sDisplayVersion
End If
WScript.Quit
End If

strKeyPath = "software\wow6432node\microsoft\windows\currentversion\uninstall"
sDisplayVersion = oWsh.Regread("HKLM\" & strKeyPath & "\" & GUIDid & "\DisplayVersion")
if err.number <> 0 then
wscript.echo "Not-Installed in 32 bit registry"
else
if(sDisplayVersion >= dVersion) Then
WScript.Echo "Up to date:" & sDisplayVersion
Else
WScript.Echo "Not up to date:" & sDisplayVersion
End If
End If
User avatar
jjimenez
Posts: 12
Joined: Sun Mar 02, 2014 12:28 pm

Re: help combining 2 scripts

Postby jjimenez » Wed Mar 05, 2014 2:02 pm

thank you very much.

Is there no way to get the error message outside of both queries to where it only returns one value if it errors.
User avatar
jvierra
Posts: 10030
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: help combining 2 scripts

Postby jvierra » Wed Mar 05, 2014 2:27 pm

The copy I posted returns only one line ever. Or it retruns towo messages saying not found.

You can restructure to save the errors until last if you want.
User avatar
jjimenez
Posts: 12
Joined: Sun Mar 02, 2014 12:28 pm

Re: help combining 2 scripts

Postby jjimenez » Wed Mar 05, 2014 2:35 pm

can you help me with that? I need it to only return one value ever. Even if it is an error.
User avatar
jjimenez
Posts: 12
Joined: Sun Mar 02, 2014 12:28 pm

Re: help combining 2 scripts

Postby jjimenez » Wed Mar 05, 2014 3:32 pm

added a wscript.quit after the first error, fixed it.

Thank you for your time :D
User avatar
jvierra
Posts: 10030
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: help combining 2 scripts

Postby jvierra » Wed Mar 05, 2014 5:02 pm

So you don't ever want to search 32 bit subsytems?

This is all you wanted:

VBScript Code
Double-click the code block to select all.
const HKEY_LOCAL_MACHINE  = &H80000002

dversion = "6.1.20913.0"
GUIDid = "{89F4137D-6C26-4A84-BDB8-2E5A4BB71E00}"
set oWsh = createobject("wscript.shell")

On Error Resume Next
strKeyPath = "softwaremicrosoftwindowscurrentversionuninstall"
sDisplayVersion = oWsh.Regread("HKLM" & strKeyPath & "" & GUIDid & "DisplayVersion")
if err.number <>0 Then
wscript.echo "Not-Installed in 32 bit registry"
Else
if(sDisplayVersion >= dVersion) Then
WScript.Echo "Up to date:" & sDisplayVersion
Else
WScript.Echo "Not up to date:" & sDisplayVersion
End If
WScript.Quit
End If

Return to “VBScript”

Who is online

Users browsing this forum: No registered users and 2 guests

cron