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

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

VBS: Write to a remote registry

Hi.

This script should read from a list of machines, go through the list and make registry changes to each machine on the list.

I'm trying to write to a remote registry. Currently I can read from a list of machines, but I cannot work out how to write to a remote registry instead of my own. The machines I am trying to write to are a mix of NT4, W2K and XP. They are in a domain. Users will be logged in while the script runs, so there will be some permissions to take into account. The script will be called and run by an administrator, from that administrators local machine.

The code:
----------------------------------------------------------------------------------------

' Declaring variables
Dim oFSO, TS, strComputer, objShell, objComputer, strSvrList, oFile, oShell, uidShell
Const ForReading = 1
Set oShell = CreateObject("Wscript.Shell")
set uidShell = WScript.CreateObject("WScript.Shell")

' Read machine names from the dupuidlist.txt file.
Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set TS = oFSO.OpenTextFile (".\ClonedUIDList.txt", ForReading)
Do While Not TS.AtEndOfStream
  strComputer = Trim(TS.ReadLine)
     
     ' Reset the UID
     On Error Resume Next

     ' Re-sets the cloned UID to zero
     uidShell.RegWrite "HKLM\SOFTWARE\ComputerAssociates\eTrustAntivirus\CurrentVersion\ID", 0, "REG_BINARY"

     ' Adds a key to aid future troubleshooting.
     uidShell.RegWrite "HKLM\SOFTWARE\ComputerAssociates\eTrustAntivirus\7.0\CurrentVersion", "New UID generated by post clone VBS"

' Msgbox when the last server on the list has been tested.
If TS.AtEndOfStream = True Then
     MsgBox "Finished resetting UID's from list",vbOk+vbInformation,"Reset UID's"
End if

' Do it all again until end of list.
' Next

Loop

TS.Close
Set TS = Nothing
Set oFSO = Nothing
Set oFile = Nothing
----------------------------------------------------------------------------------------

I am not a programmer, so I would greatly appreciate any examples you might provide. Thanks.

Brgds,
Peter
0
PLSM
Asked:
PLSM
  • 5
  • 4
  • 2
1 Solution
 
pYraniaCommented:
AFAIK you cannot write ot the remote registry. Don't know how many hours I spent coming to this solution...
0
 
merowingerCommented:
hi,
do you have tried a solution as those...
uidShell.RegWrite "HKLM\SOFTWARE\ComputerAssociates\eTrustAntivirus\7.0\CurrentVersion" \\pcname

mero
0
 
PLSMAuthor Commented:
pYrania, my research show that it is possible as long as the permissions are sorted, which could be done with a RUNAS script. I found one that will handle that. however, if that is not the only obstacle, then you're probably right.

Mero,
I have not tried that, but I certainly will. Thanks.
0
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!

 
pYraniaCommented:
My problem with it is/was, that I'm connecting to the remote computer through WMI to change the installed printers of, and here is the bogus, of a specific user.
anyway, that's another topic.

let us know if that one works.
0
 
PLSMAuthor Commented:
Hello Gents,

no, the \\pcname did not work. It seems I might need something like:

For Each "registry" In strComputer

' Reset the UID
     On Error Resume Next

     ' Re-sets the cloned UID to zero
     uidShell.RegWrite "HKLM\SOFTWARE\ComputerAssociates\eTrustAntivirus\CurrentVersion\ID", 0, "REG_BINARY"

     ' Adds a key to aid future troubleshooting.
     uidShell.RegWrite "HKLM\SOFTWARE\ComputerAssociates\eTrustAntivirus\7.0\CurrentVersion", "New UID generated by post clone VBS"
0
 
merowingerCommented:
hi maybe how have to set the "

mero
0
 
PLSMAuthor Commented:
mero,

do you mean in the "registry". I put the "" in to just mean it as some sort of reference to the registry. I don't know, maybe if the registry has been declared as a variable it can be used... but I don't know...

This is a very tricky one. I have a deadline of today to fix this, so I may close the call later today...

Brgds,
Peter
0
 
merowingerCommented:
hi,

try this

dim wshshell
set wshshell = CreateObject("WScript.Shell")
wshshell.run "REG UPDATE HKLM\SOFTWARE\ComputerAssociates\eTrustAntivirus\7.0\CurrentVersion \\pcname"


mero

for more infos: open dos box and type: reg /?
0
 
PLSMAuthor Commented:
miro,

as far as I can see there is no REG UPDATE. Other REG WHATEVER... yes...

REG DELETE might be useful.

Peter
0
 
merowingerCommented:
yes you can use update, delete, add...

mero
0
 
PLSMAuthor Commented:
mero,

I will give you the credits as your REG UPDATE comment was the inspiration I needed. The final code looks different, but it was very useful. Thanks a lot.

Peter
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 5
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now