?
Solved

VBS - Detect OS and Rewrite Reg Key value

Posted on 2014-09-12
4
Medium Priority
?
336 Views
Last Modified: 2014-09-15
Hi,

I need help to create a VBS script that will detect my OS and write the following reg key:

if W7:
REG ADD "HKLM\Software\Wow6432Node\Microsoft\SMS\Client\Client Components\Remote Control" /v Enabled /t REG_DWORD /d 1 /f

Else REG ADD "HKLM\Software\Microsoft\SMS\Client\Client Components\Remote Control" /v Enabled /t REG_DWORD /d 1 /f

good in batch file, but in VBS, i need your help.
0
Comment
Question by:mldaigle1
[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
  • 2
4 Comments
 
LVL 29

Accepted Solution

by:
becraig earned 1500 total points
ID: 40320181
My VB is really rusty and I would have suggested powershell for this (but here goes)


strComputer = "."
Set objWMIService = GetObject("winmgmts:\\"  & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)

For Each objItem in colItems
osname = objItem.Caption

if inStr(osname, "Microsoft Windows 7") then
wshShell.RegWrite "HKLM\Software\Wow6432Node\Microsoft\SMS\Client\Client Components\Remote Control\Enabled" "1", "REG_DWORD"

else
wshShell.RegWrite "HKLM\Software\Microsoft\SMS\Client\Client Components\Remote Control\Enabled" "1", "REG_DWORD"
end if 
Next

Open in new window

0
 

Author Comment

by:mldaigle1
ID: 40320408
Hi Becraig,


I agree with you, but since we still have more then 20k pc with XP, vbs is still the solution for now.  Let me try your vbs monday and i'll get back to you.

Thanks for the command lines.

:)
0
 

Author Closing Comment

by:mldaigle1
ID: 40322895
Hi becraig,

Just needed to adjust few things in the code and it worked like a charm.  Thanks a lot!

:)
0
 
LVL 29

Expert Comment

by:becraig
ID: 40323009
Great stuff glad to help.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Learn more about the importance of email disclaimers with our top 10 email disclaimer DOs and DON’Ts.
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
Articles on a wide range of technology and professional topics are available on Experts Exchange. These resources are written by members, for members, and can be written about any topic you feel passionate about. Learn how to best write an article t…

752 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