Main Page / Index

' LogonPolicy.vbs
' Script to change logon prompts on Windows 7 (and XP ?).
' Changes registry settings!!!
' This will present a logon banner and prompts for agreement before
' asking for username and password. It also blanks out the previous
' username. The legalnoticecaption should be short, but the
' legalnoticetext can be quite long (25-30 lines?)
' Suggested usage: cscript LogonPolicy.vbs > results.txt

Dim oDomain, strComputer,oLocalGroup,Item,IsOnline
Dim objWMIService, objItem, objService
Dim colListOfServices, strService
const HKEY_CURRENT_USER = &H80000001
const HKEY_LOCAL_MACHINE = &H80000002
Set StdOut = WScript.StdOut

' Enumerate all the computers in the OU specified below

Set oDomain = GetObject ("LDAP://OU=Laptops,OU=Computers,OU=Austin,DC=ad,DC=yourdomain,DC=com")

On Error Resume Next

For Each strComputer in oDomain
    strComputer = strComputer.CN
        IsOnline=PcOnline(strComputer)
        If IsOnline = True Then
                Set oShell=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
                        strComputer & "\root\default:StdRegProv")
                    oshell.setDWORDValue &H80000002,"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"_
                        ,"dontdisplaylastusername",00000001
                    oShell.SetStringValue &H80000002,"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"_
                        ,"legalnoticecaption",_
                    "Property of So & So Systems"
                    oShell.SetStringValue &H80000002,"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"_
                        ,"legalnoticetext",_
                    "Authorized Personnel Only and lots more legelese if you want"
        End If
Next

Function PcOnline (strComputer)
'Check if the remote machine is online.
    Dim objPing,objStatus
  
    Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
        ExecQuery("select Replysize from Win32_PingStatus where address = '" & strComputer & "'")

    For Each objStatus in objPing
        If  IsNull(objStatus.ReplySize) Then
            PcOnline=False
            Wscript.Echo strComputer & " is NOT available"
         Else
            PcOnline=True
            Wscript.Echo strComputer & " is responding to a ping"
          End If
    Next
    Set objPing=Nothing
    Set objStatus=Nothing
End Function





Document made with Nvu