Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 19
  • Last Modified:

Need a script to change registry value

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
John b
Asked:
John b
  • 3
1 Solution
 
Bill PrewCommented:
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
 
John bAuthor Commented:
Thanks for your quick response.
Yes, Need to modify the value if it is 10 it should be changed to 110
0
 
Bill PrewCommented:
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
 
Bill PrewCommented:
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!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now