Solved

Check Windows version then echo registry settings

Posted on 2014-03-19
3
489 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
  • 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

680 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