Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Help with a script that modifies registry

Help with a script that modifies registry

Help with a script that modifies registry

Hi, i am teaching myself vb-script using a self paced guide.
I wrote this to modify registry entries on machines listed in a text file. my problem is that it only modifies the registry of the machine i am running it from(this machine is also listed in the computers.txt file). The modification does not refelect on the other machines.Any feedback appreciated.

Const INPUT_FILE_NAME = "C:\Scripts\Computers.txt" Const FOR_READING = 1 Set objFSO = CreateObject("Scripting.FilesystemObject") Set objFile = objFSO.OpenTextFile(INPUT_FILE_NAME, FOR_READING) Dim mykey
strComputers = objFile.ReadAll objFile.Close
arrComputers = Split(strComputers, vbCrLf)

For Each strComputer In arrComputers
Set WshShell = CreateObject("WScript.Shell")
myKey = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\fDenyTSConnections"
WshShell.RegWrite myKey,0,"REG_DWORD"
Set WshShell = Nothing

RE: Help with a script that modifies registry

You might like to note that the RegWrite method has no capability for writing to the registry of anything apart from the local computer.

What you really need to look at is the WMI-provided registry functions, which do have the capability to write to a remote registry (provided you have the correct permissions).

So, assuming that your first bit of code, getting the computernames into an array is correct:


Const HKEY_LOCAL_MACHINE = &H80000002

strKeyPath = "SYSTEM\CurrentControlSet\Control\Terminal Server\"
strValuename = "fDenyTSConnections"
lValue = 0

For Each strComputer In arrcomputers
    Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
    objRegistry.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValuename, lValue

RE: Help with a script that modifies registry

Excellent, I did not know that.
I will give it a try and let you know if it worked.

RE: Help with a script that modifies registry

Excellent Advice.
Initially the script failed after i modified it. The reason for this was because of the firewall being on.
After i took it off, it executed flawlessly.

Thanks again for your advice.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close