Solved

Check Windows version then echo registry settings

Posted on 2014-03-19
3
487 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

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.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

765 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