Editing registry remotely 
Author Message
 Editing registry remotely

How do you edit the registry on a remote computer using VBScript?

TIA.



Fri, 22 Mar 2002 03:00:00 GMT  
 Editing registry remotely
Use the REGOBJ at the following site. I've been using it with much success.

http://cwashington.netreach.net

For example, I wanted to change the default date and time formats on a
remote unit so I wrote this script

'---------------------------------------------------------------------------
--------------'
'
'
'  Name:
'
'
'
'    remotedt.vbs
'
'
'
'  Description:
'
'
'
'    This script modifies the short date and time formats for the default
user on a       '
'    remote machine.
'
'
'
'  Parameters:
'
'
'
'    machineid:    the network name of the registry to modify (ie NT12946)
'
'
'
'  Notes:
'
'
'
'    See the first three lines of code to identify the changes made
'
'
'
'  Audit:
'
'
'
'    yyyy/mm/dd  ????  created
'
'
'
'---------------------------------------------------------------------------
--------------'

'these three lines identify the key, subkeys, and replacement values

const regstr = "\HKEY_USERS\.DEFAULT\Control Panel\International\"
datekey = "sShortDate"  : dateval = "yyyy/MM/dd"
timekey = "sTimeFormat" : timeval = "HH:mm:ss"

'if there are no arguments then exit

set arg = Wscript.Arguments
if arg.count = 0 then wscript.quit 0

'the argument is the name of the remote machine to modify

remote  = arg(0)
fullkey = remote & " " & regstr

'create some needed objects

set wso = CreateObject("Wscript.Shell")          'workplace shell object'
set reg = CreateObject("RegObj.Registry")        'registry object       '
set rmo = reg.RemoteRegistry(remote)             'remote registry object'

'get the remote key - exit with error message if machine or key not found

on error resume next
   set key = rmo.RegKeyFromString(regstr)
   if err.number then
      wso.PopUp "machine not found",,remote
      wscript.quit 1
   end if
on error goto 0

'default is date/time not found in case we need to add a key later

timefound = false
datefound = false

'check all of the keys in this subtree

for each obj in key.values

   'if this is the time (short format) then update it if not already done

   if obj.name  = timekey then
      timefound = true
      prevval   = obj.value
      if prevval <> timeval then
         obj.value = timeval
         wso.PopUp "changed:" & vbcrlf & vbcrlf & vbtab _
            & "old" & vbtab & prevval & vbcrlf & vbtab _
            & "new" & vbtab & obj.value,,fullkey & obj.name
      end if
   end if

   'if this is the date (short format) then update it if not already done

   if obj.name  = datekey then
      datefound = true
      prevval   = obj.value
      if prevval <> dateval then
         obj.value = dateval
         wso.PopUp "changed:" & vbcrlf & vbcrlf & vbtab _
            & "old" & vbtab & prevval & vbcrlf & vbtab _
            & "new" & vbtab & obj.value,,fullkey & obj.name
      end if
   end if

next

'if the time - short format key does not exist then add it

if not timefound then
   key.values.add timekey,timeval,1
   wso.PopUp "added:" & vbcrlf & vbcrlf & vbtab & "new" & vbtab &
timeval,,fullkey & timekey
end if

'if the date - short format key does not exist then add it

if not datefound then
   key.values.add datekey,dateval,1
   wso.PopUp "added:" & vbcrlf & vbcrlf & vbtab & "new" & vbtab &
dateval,,fullkey & datekey
end if



Wed, 27 Mar 2002 03:00:00 GMT  
 Editing registry remotely
You can use ActiveX RegEdit, http://www.pstruh.cz/help/RegEdit/library.htm

Antonin Foller


Quote:

> How do you edit the registry on a remote computer using VBScript?

> TIA.



Fri, 29 Mar 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Editing registry remotely

2. editing the Windows NT registry remotely

3. Editing registry hive remotely

4. Remotely Editing a Registry

5. Remotely retrieve registry information?

6. Retrieve registry information remotely?

7. Remotely changing a users registry

8. Reading Registry Remotely

9. How can I manipulate registry via API remotely?

10. How can I manipulate registry via API remotely?

11. Remotely pulling information from registry

12. Updating LAN Workstations registry Remotely?

 

 
Powered by phpBB® Forum Software