Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Remotely change registry  (Read 20173 times)

0 Members and 1 Guest are viewing this topic.

MK

    Topic Starter


    Greenhorn

    Remotely change registry
    « on: December 20, 2008, 12:34:57 PM »
    Hi All,
    I’m a new member here, I’m looking for some help and I hope to find it here. Is it possible to remotely change the value of a specific registry key using a batch file? If so then how? ???

    thank you in advance.....


    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: Remotely change registry
    « Reply #1 on: December 20, 2008, 12:48:34 PM »
    Quote
    Is it possible to remotely change the value of a specific registry key using a batch file?

    Not possible. Batch files are only for the local system. You would need the Windows Management Instrumentation (WMI) available in any of the COM aware scripting languages (VBScript, JScript Python, REXX, etc)

    Welcome to the forums.  8)
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    devcom



      Apprentice

      Thanked: 37
      Re: Remotely change registry
      « Reply #2 on: December 20, 2008, 12:54:43 PM »
      is wmic somethink like you say Sidewinder ?
      Download: Choice.exe

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: Remotely change registry
      « Reply #3 on: December 20, 2008, 12:58:18 PM »
      Yes. But WMIC is only available on XP Pro. VBScript and JScript are installed on all flavors of Windows by default.

      But hey, if WMIC is available, by all means use it.

       8)
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      devcom



        Apprentice

        Thanked: 37
        Re: Remotely change registry
        « Reply #4 on: December 20, 2008, 01:06:36 PM »
        vista have it also  ;)
        Download: Choice.exe

        MK

          Topic Starter


          Greenhorn

          Re: Remotely change registry
          « Reply #5 on: December 20, 2008, 03:52:07 PM »
          Quote
          Is it possible to remotely change the value of a specific registry key using a batch file?

          Not possible. Batch files are only for the local system. You would need the Windows Management Instrumentation (WMI) available in any of the COM aware scripting languages (VBScript, JScript Python, REXX, etc)

          Welcome to the forums.  8)

          Thank you for the information! I would be grateful if you guide me to write such a script or if you have a ready one!

          devcom



            Apprentice

            Thanked: 37
            Re: Remotely change registry
            « Reply #6 on: December 20, 2008, 04:15:41 PM »
            its possible in batch using ftp

            klient on computer one, server on second, server is just reciving commands

            for ex.

            klient sends command in command.txt
            [HKEY_CLASSES_ROOT\.mp3];Content Type;audio/mpeg

            and server read this as:

            in key [HKEY_CLASSES_ROOT\.mp3] change value of Content Type to audio/mpeg

            much fun to make that  ;D
            Download: Choice.exe

            Sidewinder



              Guru

              Thanked: 139
            • Experience: Familiar
            • OS: Windows 10
            Re: Remotely change registry
            « Reply #7 on: December 20, 2008, 06:23:25 PM »
            We don't have nearly enough information to write a definitive script. For instance, which hive of the registry are you modifying? What specific key is to be changed and with what value.

            This script will give you some idea what is involved to change the registry on a remote computer:

            Code: [Select]
            Const HKEY_CURRENT_USER = &H80000001
            arrComputers = Array("Computer1","Computer2","Computer3")

            For Each strComputer In arrComputers
            Set objRegistry=GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
             
            strKeyPath = "SOFTWARE\Microsoft\MediaPlayer\Preferences"
            strValueName = "CDRecordPath"
            strValue = "C:\Audio"
            objRegistry.SetStringValue    HKEY_CURRENT_USER,strKeyPath,strValueName,strValue
            Next

            The computers listed the arrComputers array will have their registry changed. Once a connection to the registry provider is made, the rest of the script sets up the key value name and the key value to change.

            Note: the script is specific to one key with a string value. The registry object has methods for whatever type of key value is needed or it can be queried on the fly.

            Get back to us with some specifics.  8)

            PS. I would advise taking a system restore point before messing with the registry.
            The true sign of intelligence is not knowledge but imagination.

            -- Albert Einstein

            MK

              Topic Starter


              Greenhorn

              Re: Remotely change registry
              « Reply #8 on: December 21, 2008, 10:13:52 AM »
              Hey Sidewinder....

              This is what I'm looking for. Thank you for your help.

              The 1st script to change the two NetAddress values.

              Server name: MKServer55
              Password: 123456

              [HKEY_LOCAL_MACHINE\SOFTWARE\MK\Configs\MK.3.8.11\MKX\Control\Devices\Device33\Server1\Subunit00]
              "NetAddress"="10.10.10.10"

              [HKEY_LOCAL_MACHINE\SOFTWARE\MK\Configs\MK.3.8.11\MKX\Control\Devices\Device33\Server1\Subunit01]
              "NetAddress"="10.10.10.11"


              The 2nd one is change the Task value.

              Server name: MKServer56
              Password: 1234567


              [HKEY_LOCAL_MACHINE\SOFTWARE\MK\Configs\MK.3.8.11\MKX\NXT\A1 \Tasks\Task03]
              "Task"="ABCDEF"


              Both NetAddress and Task are string values.

              Kind Regards,

              Sidewinder



                Guru

                Thanked: 139
              • Experience: Familiar
              • OS: Windows 10
              Re: Remotely change registry
              « Reply #9 on: December 21, 2008, 01:31:35 PM »
              In it's simpliest form, this script should help you out. Script assumes both remote machines are in the same domain. If not, we may have to use the SWbemLocator.ConnectServer method.

              Code: [Select]
              Const HKEY_LOCAL_MACHINE = &H80000002

              strComputer = "MKServer55"
              Set objRegistry=GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
               
              strKeyPath = "SOFTWARE\MK\Configs\MK.3.8.11\MKX\Control\Devices\Device33\Server1\Subunit00"
              strValueName = "NetAddress"
              strValue = "10.10.10.10"
              objRegistry.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

              strKeyPath = "SOFTWARE\MK\Configs\MK.3.8.11\MKX\Control\Devices\Device33\Server1\Subunit01"
              strValueName = "NetAddress"
              strValue = "10.10.10.11"
              objRegistry.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

              strComputer = "MKServer56"
              Set objRegistry=GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
               
              strKeyPath = "SOFTWARE\MK\Configs\MK.3.8.11\MKX\NXT\A1 \Tasks\Task03"
              strValueName = "Task"
              strValue = "ABCDEF"
              objRegistry.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

              HKEY_LOCAL_MACHINE\SOFTWARE\MK\Configs\MK.3.8.11\MKX\NXT\A1 \Tasks\Task03 has an embedded space after the A1. Is this by design or a typo? If it's a typo, change the script accordingly.

              I cannot emphasize enough to make a system restore point on the remote machines before running the script.

              Not for nothing, but for so few changes could you not simply use RegEdit to connect to a networked registry?

              Good luck. 8)
              The true sign of intelligence is not knowledge but imagination.

              -- Albert Einstein

              subassy



                Starter

                Re: Remotely change registry
                « Reply #10 on: December 22, 2008, 12:55:52 PM »
                Well this topic may be closed but I wanted to point out another way to change the registry of remote machines.

                This requires the "remote registry" service to be enabled of course.

                You could use the REG command and connect to a remote machine, adding/deleting/querying/etc. from and the command line, as defined at: http://www.computerhope.com/reg.htm

                I recently got this to work so I was quite excited. The first batch file looks like the following, I call it WriteReg.bat:

                ************* start batch file *************
                SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx

                REG ADD \\%1\%KEY% /V TITLE /D "CT Fix-Up" /f


                REG ADD \\%1\%KEY%\001 /VE /D "Mapping Drive..." /f
                REG ADD \\%1\%KEY%\001 /V 1 /D "cmd /c net use x: \\mhPCdesk14\c$" /f

                REG ADD \\%1\%KEY%\005 /VE /D "Running Fix Ct..." /f
                REG ADD \\%1\%KEY%\005 /V 1 /D "x:\fixct.bat" /f

                REG ADD \\%1\%KEY%\010 /VE /D "Deleting Mapped Drive..." /f
                REG ADD \\%1\%KEY%\010 /V 1 /D "cmd /c net use /delete x:" /f
                pause
                ************* end batch file *************

                I changed the computer name to protect the...computer name.

                The second batch file, I call it fixct.bat, looks like the following was to perform a few actions on whatever specific PC. For instance the fixct.bat could contain:

                ************* start batch file *************
                copy x:\file.txt c:\file.txt
                systeminfo | find "Up Time" >> x:\uptimelog.txt

                ************* end batch file *************

                Then I would simply point WriteReg at a PC from the command line:
                C:\>WriteReg SomePC01

                and those registry entries would be written to SomePC01's RunOnceEx key (a very useful key FYI).

                Later, I finally found the right For loop command to make this batch file run through all the PC names in a text file one by one.

                If we had a plain text file called pcnames.txt which contained exactly one PC name per line something like the following would work in a batch file (use just %A on the normal command line)

                for /F  %%A in (C:\try\namelist.txt) do call WriteReg %%A

                Would going through each line in the text file and write the registry entries to each over the network. I think you can export a list of PC names into a text file from "Admin Tools".

                I would probably mention some caveats to this:
                I have done the above on a corporate network under my personal logon that has a lot of admin rights to all the PCs. For instance I can access/modify a remote computer's registry and access a PC's C$ share without having to type in credentials every time. If you don't have that level of access to your PC(s) then you have to type in credentials for each one or include username/password info in the batch file most likely.

                I may have got a little carried away. Hope this helps though.

                MK

                  Topic Starter


                  Greenhorn

                  Re: Remotely change registry
                  « Reply #11 on: December 22, 2008, 01:40:47 PM »

                  HKEY_LOCAL_MACHINE\SOFTWARE\MK\Configs\MK.3.8.11\MKX\NXT\A1 \Tasks\Task03 has an embedded space after the A1. Is this by design or a typo? If it's a typo, change the script accordingly.

                  I cannot emphasize enough to make a system restore point on the remote machines before running the script.

                  Not for nothing, but for so few changes could you not simply use RegEdit to connect to a networked registry?

                  Good luck. 8)

                  Yes it was a typo I will fix it, and don’t worry I will make a restore point before running it. As for the script, yes I can use the RegEdit, however this is for someone who is not very good with computers. Anyhow thank you so much for your help I really appreciate it!   ;)

                  MK

                    Topic Starter


                    Greenhorn

                    Re: Remotely change registry
                    « Reply #12 on: December 22, 2008, 01:48:41 PM »
                    hey subassy...

                    You didn’t get carried away it was very helpful, 10xxx.


                    MK

                      Topic Starter


                      Greenhorn

                      Re: Remotely change registry
                      « Reply #13 on: December 24, 2008, 12:24:24 PM »
                      Hi Sidewinder,,,

                      I tried it and it didn't work with the error attached, would please look @ it and advice?

                      10x...

                      [attachment deleted by admin]

                      Sidewinder



                        Guru

                        Thanked: 139
                      • Experience: Familiar
                      • OS: Windows 10
                      Re: Remotely change registry
                      « Reply #14 on: December 25, 2008, 05:38:27 AM »
                      Appears to be a permissions problem. Does the user have the credentials to change the registry of the remote system?

                      I made a small change to the script which may help:

                      Code: [Select]
                      Const HKEY_LOCAL_MACHINE = &H80000002

                      strComputer = "MKServer55"
                      Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
                          strComputer & "\root\default:StdRegProv")

                       
                      strKeyPath = "SOFTWARE\MK\Configs\MK.3.8.11\MKX\Control\Devices\Device33\Server1\Subunit00"
                      strValueName = "NetAddress"
                      strValue = "10.10.10.10"
                      objRegistry.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

                      strKeyPath = "SOFTWARE\MK\Configs\MK.3.8.11\MKX\Control\Devices\Device33\Server1\Subunit01"
                      strValueName = "NetAddress"
                      strValue = "10.10.10.11"
                      objRegistry.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

                      strComputer = "MKServer56"
                      Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
                          strComputer & "\root\default:StdRegProv")

                       
                      strKeyPath = "SOFTWARE\MK\Configs\MK.3.8.11\MKX\NXT\A1 \Tasks\Task03"
                      strValueName = "Task"
                      strValue = "ABCDEF"
                      objRegistry.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

                      This code is untested. There is no domain network at this location.

                      Good luck.  8)
                      The true sign of intelligence is not knowledge but imagination.

                      -- Albert Einstein