none
LTICleanUp autologon If\Then\Else RRS feed

  • Question

  • In my LTICleanup.wsf I want to by pass the AutoAdmin Clean\Removal

    I have a TS to create a registry 

    HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\BypassWinlogonCleanUp

    When the LTICleanUp runs it should see the registry and bypass the clean up due to the If\Then\Else for the Auto Admin, but I'm getting errors, and its only for this section of the script which I updated.W

    What I' using for this part of the script is below... Thanks


    '//----------------------------------------------------------------------------
    '//  Clear the autologon registry keys
    '//----------------------------------------------------------------------------

    oLogging.CreateEntry "Removing AutoAdminLogon registry entries", LogTypeInfo

    On Error Resume Next

    Dim Value

    Value=RegKeyExists("HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\BypassWinlogonCleanUp")

    If Value=0 Then
     
     oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoAdminLogon", "1", "REG_SZ"
     oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName", "myuser@somedomain.com", "REG_SZ"
     oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName", "somedomain.com", "REG_SZ"
     oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultPassword", "some_password", "REG_SZ"
     oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoLogonCount", "0", "REG_SZ"
    Else
     
     oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoAdminLogon", "0", "REG_SZ"
     oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName", "", "REG_SZ"
     oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName", "", "REG_SZ"
     oShell.RegDelete "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultPassword"
     oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoLogonCount", &H00000000, "REG_DWORD"
     
    End If

     

    Function RegKeyExists(Key)
      Dim entry
      On Error Resume Next
     
      
      entry = oShell.RegRead(Key)
      If Err.Number = 0 Then
        Err.Clear
        RegKeyExists = False
      Else
        Err.Clear
        RegKeyExists = True
      End If
    End Function
    On Error Goto 0

    Monday, November 11, 2019 3:52 PM

Answers

  • Dim sKey, sValue, sKeyFound
    sKey = "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\BypassWinlogonCleanUp"
    Set oShell = CreateObject("WScript.Shell") 'this can be removed in the actual script
        on error resume next            ' turn off error trapping
        sValue = oShell.regread(sKey)       ' read attempt
        sKeyFound = (err.number = 0)     ' test for success
    
    If sKeyFound Then
    MsgBox "Key Exist and sKeyFound value = " & sKeyFound 'Replace with details of autologon registries
    	  Else
    MsgBox "Key Doesn't Exist and sKeyFound value = " & sKeyFound 'Replace with LTI Cleanup of auto logon registries
    End If

    • Marked as answer by biziee Thursday, November 14, 2019 10:55 AM
    Thursday, November 14, 2019 10:55 AM