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
        If IsOnline = True Then
                Set oShell=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
                        strComputer & "\root\default:StdRegProv")
                    oshell.setDWORDValue &H80000002,"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"_
                    oShell.SetStringValue &H80000002,"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"_
                    "Property of So & So Systems"
                    oShell.SetStringValue &H80000002,"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"_
                    "Authorized Personnel Only and lots more legelese if you want"
        End If

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
            Wscript.Echo strComputer & " is NOT available"
            Wscript.Echo strComputer & " is responding to a ping"
          End If
    Set objPing=Nothing
    Set objStatus=Nothing
End Function

Document made with Nvu