I’m new to scripting and currently the IT admin over a domain controller with several other companies set up in their own OU. In an effort to restate our company’s computer use policy I am trying to update the registry’s “LegalNoticeText” for each PC (85). I found the following script (fig 1) and ran it locally for my PC and it worked fine. I then needed a way to do this over the network on each PC. I first attempted to add this to the GroupPolicy startup/shutdown, but it did not work and I’m not sure why. So I then thought a script would work to update each pc remotely and I found this script fig (2) and inserted the first script into it at the required location. I set up a .txt file with all of our computer names and saved it in the folder as indicated in the script. However when I ran the script it did not use the file at all and it started updating computers that were not in my OU. I quickly stopped it and corrected the computers that were updated. I also realized that I need admin permissions to update the registry.
Why didn't the script use the file at the location indicated?
How can I make this work using Administrator Permissions remotely? Thanks in advance
Thanks in Advance
Fig (1)
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objReg=GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
strValueName = "LegalNoticeCaption"
strValue = "Legal Notice"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
strValueName = "LegalNoticeText"
strValue = "By logging on to this computer you agree to abide by the "
strValue = strValue & "computer usage rules and regulations of this company."
strValue = strValue & vbCrLf & vbCrLf
strValue = strValue & "Permissible Use"
strValue = strValue & vbCrLf & vbCrLf
strValue = strValue & "E-Mail –Computer information systems are prohibited from using Electronic mail to pass jokes, chain letters, general advertisement postings, etc. and should discourage receipt of the same from people outside of the company."
strValue = strValue & vbCrLf & vbCrLf
strValue = strValue & "Internet Usage – All employees have access to the Internet for business-related activities during business hours. Non-business usage is allowed, but with no exception during business hours. Please remember that inappropriate use of the Internet will not be tolerated at any time."
strValue = strValue & vbCrLf & vbCrLf
strValue = strValue & "Content – Any inappropriate content sent or received by an employee either through the Internet or electronic mail is prohibited. Remember that all content is logged on a daily basis."
strValue = strValue & vbCrLf & vbCrLf
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
fig (2)
On Error Resume Next
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("c:\scripts\computers.txt", ForReading)
Do Until objTextFile.AtEndOfStream
strComputer = objTextFile.Readline
' =====================================================================
' Insert script here
' =====================================================================
Set objComputer = GetObject("WinNT://" & strComputer & "")
objComputer.Filter = Array("User")
For Each objUser in objComputer
Wscript.Echo objUser.Name
Next
' =====================================================================
' End
' =====================================================================
Loop
objTextFile.Close