Solved

Need a script to change registry value

Posted on 2016-10-12
5
13 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 53

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 53

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 53

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

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…
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

773 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