Solved

Need a script to change registry value

Posted on 2016-10-12
5
9 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
  • 3
5 Comments
 
LVL 51

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 51

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 51

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now