Solved

Check Windows version then echo registry settings

Posted on 2014-03-19
3
481 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 26

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 26

Expert Comment

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

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
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 fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now