Solved

VBS: Write to a remote registry

Posted on 2004-08-03
11
5,471 Views
Last Modified: 2012-06-22
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
Comment
Question by:PLSM
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
11 Comments
 
LVL 3

Expert Comment

by:pYrania
ID: 11701148
AFAIK you cannot write ot the remote registry. Don't know how many hours I spent coming to this solution...
0
 
LVL 31

Expert Comment

by:merowinger
ID: 11701389
hi,
do you have tried a solution as those...
uidShell.RegWrite "HKLM\SOFTWARE\ComputerAssociates\eTrustAntivirus\7.0\CurrentVersion" \\pcname

mero
0
 

Author Comment

by:PLSM
ID: 11702825
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!

 
LVL 3

Expert Comment

by:pYrania
ID: 11702901
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
 

Author Comment

by:PLSM
ID: 11705236
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
 
LVL 31

Expert Comment

by:merowinger
ID: 11706831
hi maybe how have to set the "

mero
0
 

Author Comment

by:PLSM
ID: 11712854
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
 
LVL 31

Accepted Solution

by:
merowinger earned 500 total points
ID: 11712909
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
 

Author Comment

by:PLSM
ID: 11713688
miro,

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

REG DELETE might be useful.

Peter
0
 
LVL 31

Expert Comment

by:merowinger
ID: 11713697
yes you can use update, delete, add...

mero
0
 

Author Comment

by:PLSM
ID: 11714802
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

Independent Software Vendors: 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!

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Introduction to Processes

624 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