Solved

VBS - Detect OS and Rewrite Reg Key value

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Title # Comments Views Activity
android app- saved password.. 7 85
will india ph work in usa? 21 92
how to count files? 4 55
Best CRM to customize - Free / less fee 2 42
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…
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
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…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

749 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