Solved

Need a script to change registry value

Posted on 2016-10-12
5
15 Views
Last Modified: 2016-11-01
The registry key location is: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tomcat8 the Value name we are after is "Type" and the Value Data will be set to 110 if it is set and 10 if it is off (both are Hexadecimal Base)


Could anyone please help me on this.
0
Comment
Question by:John b
[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
  • 3
5 Comments
 
LVL 54

Expert Comment

by:Bill Prew
ID: 41840533
Not sure what you mean by "if it is set" and "if it is off"?  Do you mean swap values, if 10 make it 110, if 110 make it 10?  Or something else?

~bp
0
 

Author Comment

by:John b
ID: 41840544
Thanks for your quick response.
Yes, Need to modify the value if it is 10 it should be changed to 110
0
 
LVL 54

Expert Comment

by:Bill Prew
ID: 41840591
Okay.  Also, please clarify the registry data type, it has to be one of the ones listed on this link.  I would suggest you use REGEDIT to check the data type of this value.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms724884(v=vs.85).aspx

~bp
0
 
LVL 54

Accepted Solution

by:
Bill Prew earned 500 total points (awarded by participants)
ID: 41840622
Assuming it's a DWORD which is pretty common, here is a starting point for you, see if this makes sense.  You will need to run this from an elevated command prompt since it updates the registry.

' Define registry path to value to manipulate
strKey = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tomcat8\Type"

' Create Shell object
Set objShell = CreateObject("Wscript.Shell")

' Trap errors in code
On Error Resume Next
 
' See if we can read the current value
strValue = objShell.RegRead(strKey)

' Check if we read it
If Err.Number = 0 Then
   ' Display current value (debugging)
   WScript.Echo "Current value = " & strValue

   ' Update value if needed
   If strValue = 10 Then
      objShell.RegWrite strKey, 110, "REG_DWORD"
   End If
Else
   ' Error reading current value, display error (debugging)
   WScript.Echo "Registry key not found."
End If

Open in new window

~bp
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

751 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