Solved

VBS - Detect OS and Rewrite Reg Key value

Posted on 2014-09-12
4
320 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
  • 2
  • 2
4 Comments
 
LVL 28

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 28

Expert Comment

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

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
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.
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
The Bounty Board allows you to request an article or video on any technical topic, or fulfill a bounty request to earn points. Watch this video to learn how to use the Bounty Board to get the content you want, earn points, and browse submitted bount…

762 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

18 Experts available now in Live!

Get 1:1 Help Now