Solved

Check Windows version then echo registry settings

Posted on 2014-03-19
3
492 Views
Last Modified: 2014-03-19
Hi All,

I need to check which version of windows is running first then I need to check registry settings and echo what is the current setting.

After that I need to be able to change it through a input box and verify that the change has taken place.

Can anyone please help. I have not been able to figure it out.

Thanks,
Vicki
0
Comment
Question by:Vicki05
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
MacroShadow earned 500 total points
ID: 39940238
Not sure exactly what the workflow is, so I'll give you some snippets that you can put together.

This will return the installed OS:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\"  & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
    Wscript.Echo objOperatingSystem.Caption & "  " & objOperatingSystem.Version
Next

Open in new window


This will return the value of a registry key:
Const HKEY_CLASSES_ROOT 	= &H80000000
Const HKEY_CURRENT_USER 	= &H80000001
Const HKEY_LOCAL_MACHINE 	= &H80000002
Const HKEY_USERS 		= &H80000003
Const HKEY_CURRENT_CONFIG 	= &H80000005
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\YourSoftware\Settings"
strValueName = "Setting"
objRegistry.GetStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, strValue
Wscript.Echo strValue

Open in new window


This will change a value of a registry key based on inputbox:
Const HKEY_CLASSES_ROOT 	= &H80000000
Const HKEY_CURRENT_USER 	= &H80000001
Const HKEY_LOCAL_MACHINE 	= &H80000002
Const HKEY_USERS 		= &H80000003
Const HKEY_CURRENT_CONFIG 	= &H80000005
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\YourSoftware\Settings"
strValueName = Inputbox("Enter New Value.")
objRegistry.SetStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, strValue
Wscript.Echo strValue

Open in new window


Note:
In the objRegistry.SetStringValue line change HKEY_CURRENT_USER to match the hive containing your key.
0
 

Author Closing Comment

by:Vicki05
ID: 39940518
Hi MacroShadow,


I will try to use the solution you provided.


Thanks a lot.
Vicki.
0
 
LVL 27

Expert Comment

by:MacroShadow
ID: 39940636
You're welcome.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question