Solved

VBS: Write to a remote registry

Posted on 2004-08-03
11
5,460 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
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.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

758 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

11 Experts available now in Live!

Get 1:1 Help Now