Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make a choice and display a prompt

Status
Not open for further replies.

Ednetman

Technical User
May 20, 2002
54
US
I have a script that works fine as a standalone. I now need to embed some logic in to it. I need for it to look at the results and make a decision based on what it finds. here is my script:

**************************************************************
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
const REG_SZ = 1
const REG_EXPAND_SZ = 2
const REG_BINARY = 3
const REG_DWORD = 4
const REG_MULTI_SZ = 7

strOriginalKeyPath = "SYSTEM\CurrentControlSet\Control\Class"

FindKeyValue(strOriginalKeyPath)

'-------------------------------------------------------------------------
Function FindKeyValue(strKeyPath)

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")

errorCheck = oReg.EnumKey(HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys)

If (errorCheck=0 and IsArray(arrSubKeys)) then
For Each subkey In arrSubKeys
strNewKeyPath = strKeyPath & "\" & subkey
FindKeyValue(strNewKeyPath)
Next
End If

oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, _
arrValueNames, arrValueTypes

If (errorCheck=0 and IsArray(arrValueNames)) then
For i=0 To UBound(arrValueNames)
'Wscript.Echo "Value Name: " & arrValueNames(i)
if arrValueNames(i) = "PnPCapabilities" then
strValueName = arrValueNames(i)
oReg.GetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue
wscript.echo "HKEY_LOCAL_MACHINE\" & strkeyPath & vbNewLine & "Contains: " & dwValue
end if
Next
End If

end Function

**************************************************************

What I need to do i add something like this:
**************************************************************
Select Case dwValue
If dwValue = "32" Then
WScript.Echo "Wake On LAN is enabled."
Else
If dwValue = "288" Then
wscript.Echo "Wake On LAN is enabled."
Else
If Else: wscript.Echo "Wake On LAN is NOT enabled, please correct this now."
End If
**************************************************************

I have two values that = "ON" and any other value, or no value found needs to = "OFF"

Anybody have any ideas?

Ed
 
Select Case dwvalue
Case "32", "288"
wscript.Echo "Wake On LAN is enabled."
Case Else
wscript.Echo "Wake On LAN is NOT enabled, please correct this now."
End Select
 
Thanks! I tried your code and I got the same thing that I got in my version. The first prompt (that I'll supress later) echoes 32 but then I get the "Not enabled" message box.

I added it right after the line "End Function"

Am I doing something wrong?
 
Why don't you rewrite the whole function? It is badly conceived! and passing variable dwValue like that is typically speghetti!
 
Sorry, the guy who usually writes this stuff quit. I am trying to piece together from the Internet, old scripts, etc.

Until I get a class or a book or something, I will have to ask for a lot of help. This was the best I could do given my limited experience.

Can you make it work better? I would appreciate any help.

Thanks!

Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top