Solved

Need a script to change registry value

Posted on 2016-10-12
5
16 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 56

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 56

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 56

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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

630 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