LegalText.vbs
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
'~ SCRIPT NAME: LEGALNOTICE.VBS | |
'~ WRITTEN BY: JON BRYAN - March 2010 | |
'~ | |
'~ This script should be applied as a machine startup script that applies to all machines in a Domain. | |
'~ | |
'~ It applies the Legal Text to all machines except those in the "AUTO_BOOT_PC" security group. This is a Security Group in your own Domain. | |
'~ | |
'~ Before applying this script, remember to remove the 'normal' GPO settings found in: | |
'~ Computer Configuration/Windows Settings/Local Policies/Security Options - | |
'~ Interactive logon: Message title for users attempting to log on | |
'~ Interactive logon: Message text for users attempting to log on | |
'~ | |
'~ The basis of the Sub was taken from the Scripting Guy's site: | |
'~ http://blogs.technet.com/heyscriptingguy/archive/2005/01/17/how-can-i-change-the-legal-warning-message-using-a-script.aspx | |
'~ Although, I have made some changes that affect the layout - initial blank line and indented text (VbTab fails to effect Windows 7 - so spaces | |
'~ used - works universally) and have made their stand-alone script into a Sub that is called only if the machine is not a member of a group. | |
'~ | |
'~ UPDATED 07/03/12 - Computers in multiple groups caused the legal text to be written in some cases, as the script evaluated group memberships. | |
'~ I have sorted this by writing group names to an array, then making a string of the array values, then looking for the string "AUTO_BOOT_PC" within that string! | |
'~ Additionally the script clears registry values if the computer is in that group. Alternatively, if the computer is not in the group, the registry values are written! | |
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
Option Explicit | |
On Error Resume Next | |
Dim objSysInfo, objComputer, strComputerDN, strComputer, objReg, strKeyPath, strValueName, strValue, strList, strGroup, arrGroups | |
Set objSysInfo = CreateObject("ADSystemInfo") | |
strComputerDN = objSysInfo.ComputerName | |
Set objComputer = GetObject("LDAP://" & strComputerDN) | |
arrGroups = objComputer.memberOf | |
If IsEmpty(arrGroups) Then | |
'Wscript.Echo "No Groups!" | |
Wscript.Quit | |
ElseIf (TypeName(arrGroups) = "String") Then | |
strList=arrGroups | |
Decisions | |
Else | |
For Each strGroup In arrGroups | |
If strList="" Then | |
strList=strGroup | |
Else | |
strList = strList & ";" & strGroup | |
End If | |
Next | |
Decisions | |
End If | |
'Wscript.Echo "GroupArray: " & strList | |
Sub Decisions | |
If Instr(strList,"CN=AUTO_BOOT_PC") Then | |
'Wscript.Echo "Clearing Legal Text" | |
ClearLegalText | |
Else | |
'Wscript.Echo "Writing Legal Text" | |
LegalText | |
End If | |
End Sub | |
Sub LegalText | |
Const HKEY_LOCAL_MACHINE = &H80000002 | |
strComputer = "." | |
Set objReg=GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv") | |
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" | |
strValueName = "LegalNoticeCaption" | |
strValue = "STFC Policy Notice:" | |
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue | |
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" | |
strValueName = "LegalNoticeText" | |
strValue = "" | |
strValue = strValue & vbCrLf & vbCrLf | |
strValue = strValue & " " & "Access to this system is restricted to blah, blah." | |
strValue = strValue & vbCrLf & vbCrLf | |
strValue = strValue & " " & "blah, blah " | |
strValue = strValue & vbCrLf | |
strValue = strValue & " " & "blah, blah" | |
strValue = strValue & vbCrLf & vbCrLf | |
strValue = strValue & " " & "blah, blah " | |
strValue = strValue & vbCrLf | |
strValue = strValue & " " & "blah, blah " | |
strValue = strValue & vbCrLf | |
strValue = strValue & " " & "blah, blah " | |
strValue = strValue & vbCrLf | |
strValue = strValue & " " & "blah, blah" | |
strValue = strValue & vbCrLf & vbCrLf | |
strValue = strValue & " " & "We are watching you, so don't be naughty! :)." | |
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue | |
End Sub | |
Sub ClearLegalText | |
Const HKEY_LOCAL_MACHINE = &H80000002 | |
strComputer = "." | |
Set objReg=GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv") | |
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" | |
strValueName = "LegalNoticeCaption" | |
strValue = "" | |
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue | |
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" | |
strValueName = "LegalNoticeText" | |
strValue = "" | |
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment