Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VBS: Write to a remote registry

Posted on 2004-08-03
11
Medium Priority
?
5,475 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
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
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 1500 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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
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 …
Simple Linear Regression

715 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