Solved

VBS - Detect OS and Rewrite Reg Key value

Posted on 2014-09-12
4
333 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 500 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
Learn more about the importance of email disclaimers with our top 10 email disclaimer DOs and DON’Ts.
Notifications on Experts Exchange help you keep track of your activity and updates in one place. Watch this video to learn how to use them on the site to quickly access the content that matters to you.
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

688 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