Solved

VBS: Write to a remote registry

Posted on 2004-08-03
11
5,464 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
count8 challlenge 13 118
mapBully challenge 6 114
how to update exe applicatio from internet ? 6 67
C# Error - Add Failed 12 78
A short article about a problem I had getting the GPS LocationListener working.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now