Solved

VBS - Detect OS and Rewrite Reg Key value

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

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

Suggested Solutions

One of the biggest challenges facing freelancers is balancing multiple projects and deadlines. Organizational skills and time management are key to keeping up with projects and staying on track. Luckily, we’ve curated seven tools to help you focus o…
With the shift in today’s hiring climate (http://blog.experts-exchange.com/ee-blog/5-tips-on-succeeding-in-the-new-gig-economy/?cid=Blog_031816), many companies are choosing to hire freelancers to get projects completed efficiently and inexpensively…
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.
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…

808 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