|
Recently I have been playing around with VBS and I have just finished creating this small script that will go through every IP in a range and update the folder C:\Windows\System32\GroupPolicy from the local location of C:\Scripts\GroupPolicy. I find this helpful when I have multiple sites in a VPN but not on the domain, I can then adjust Startup\Shutdown scripts without having to log on to each one remotely. '********************************************************************** ' UpdateRemoteFolder.vbs ' ' This script will copy the GroupPolicy folder from C:\Scripts to ' the remote location \\remoteIPaddress\C$\Windows\System32\GroupPolicy ' Create a folder C:\Scripts ' ' Log will append to end of file ' ' Author......: Gary Smith, TheAwkward.Net ' Date Written: 01/06/2009 ' ' Usage: UpdateRemoteFolder.vbs >> log.txt ' ' Notes: ' For each IP in range result will be written to a log ' To output result to a log please run as follows ' c:\loctionofscript\> Cscript UpdateRemoteFolder.vbs >> log.txt ' ' To output to screen with out log run as follows ' c:\loctionofscript\> Cscript UpdateRemoteFolder.vbs ' '********************************************************************** Option Explicit Dim net, fso, strSubnetPrefix, intStartSubnet, intEndSubnet, i Dim remoteCom, remoteShare, user, password Set net = CreateObject("WScript.Network") Set fso = CreateObject("Scripting.FileSystemObject")
user = "workgroup\Administrator" password = "Password1"
strSubnetPrefix = InputBox("Please enter the IP range. E.G ""10.3.11.""", "TheAwkward.net, Update Remote Group Policy Folder") intStartSubnet = 1 intEndSubnet = 254
On Error Resume Next For i = intStartSubnet To intEndSubnet remoteCom = strSubnetPrefix & i remoteShare = "\\" & remoteCom & "\admin$" net.MapNetworkDrive "", remoteShare, False, user, password If err.number Then wscript.echo remoteCom & " is not a Windows machine. " & date() & " " & time () Err.Clear Else With fso.GetFolder("C:\scripts") If .Subfolders.Count Then _ fso.CopyFolder "C:\scripts\*", remoteShare & "\system32\" If .Files.Count Then _ fso.CopyFile "C:\scripts\*", remoteShare & "\system32\" End With wscript.echo remoteCom & " is now updated. " & date() & " " & time () net.RemoveNetworkDrive remoteShare End If Next ' '**********************************************************************
|