VBScript to find a specific environment variable

I am looking for a script that will find a specific variable on a Windows XP machine.  I would like the script to prompt for a computer name in the domain and return a yes/no type of answer to whether or not the variable is present.  Do any of you experts know if this is possible?

For example, I would like to start the script, have a input box come up and say: enter a machine name.  Once I do this all I want it a yes/no response.  Does anyone out there have any suggestions on this one?

This would be a specific system variable that I pushed to all of my machines in the domain with SMS 2003.  I just need to confirm this is the user calls in with an issue and a script would be the best for me to save time.

Please send whatever you can.

Thanks in advance.
LVL 2
wiggs1006Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris DentPowerShell DeveloperCommented:

The Environmental Variables are accessible as part of the Win32_Environment node in WMI. You'll have to fill in the Variable Name of course...


Const VARIABLE_NAME = "<Variable Name>"

Const WBEM_RETURN_IMMEDIATELY = &H10
Const WBEM_FORWARD_ONLY = &H20

strComputer = InputBox("Enter Computer Name")

booIsPresent = False
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Environment", "WQL", _
            WBEM_RETURN_IMMEDIATELY + WBEM_FORWARD_ONLY)

For Each objItem in colItems
      If objItem.SystemVariable = True Then
            If objItem.Name = VARIABLE_NAME Then
                  booIsPresent = True
            End If
      End If
Next

If booIsPresent = True Then
      MsgBox "Yes"
Else
      MsgBox "No"
End If

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
EDDYKTCommented:
just use inputbox and msgbox?

dim response

response = inputbox("enter computer name", "computer name")
response = msgbox("are you sure " & response)
wscript.echo response
EDDYKTCommented:
forget it, i misread your question
wiggs1006Author Commented:
Thanks for the help, I was almost there!

Nice work!
Chris DentPowerShell DeveloperCommented:

Pleasure :)

Chris
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.