Jump to content
Sign in to follow this  
Rex

Autologon on WinXP

Recommended Posts

Rex

This is just a little somthing, i did to help some friends

; Generated by NewScript 4.5
;----------------------------------------------------------------------------
; Created:          06-05-2007 13:02:23
; Author:           Johnny Rex
; Mail:             RexprivatAThotmailDOTcom
; Version:          1.0
; AutoitVer:        3.1.1.119
; AutoItForum:      
; Script Function:
; Enables or disables Auto logon on Wndows XP
; Changelog:
;
; ----------------------------------------------------------------------------
#include <GUIConstants.au3> ; Includes GUIConstants.au3 to script
; Opt's Start > --------------------------------------------------------------
; Opt("RunErrorsFatal", 1)        ;1=fatal, 0=silent set @error
 Opt("GUIOnEventMode", 1)        ;0=disabled, 1=OnEvent mode enabled
; Opt("GUICloseOnESC", 1)         ;1=ESC  closes, 0=ESC won't close
; Opt("TrayIconDebug", 0)         ;0=no info, 1=debug line info
; Opt("TrayMenuMode",0)           ;0=append, 1=no default menu, 2=no automatic check, 4=menuitemID  not return
; Opt("TrayOnEventMode",0)        ;0=disable, 1=enable
 Opt("TrayIconHide", 1)          ;0=show, 1=hide tray icon
; Opt("TrayAutoPause",1)          ;0=no pause, 1=Pause
; Opt's End > ----------------------------------------------------------------
; Script start

Global $Pass_1, $Pass_2, $Pass_Check, $Pass_Check2, $Pass_Check_OK

#Region ### START Koda GUI section ###
$AutoLogon = GUICreate(" Force Autologon", 365, 208, -1, -1, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS))
$User_Name = GUICtrlCreateInput("", 16, 24, 329, 30, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY))
GUICtrlSetData(-1, @UserName)
;GUICtrlSetState(-1, $GUI_Disable)
GUICtrlSetFont(-1, 14, 400, 0, "Arial")
GUICtrlSetColor(-1, 0x800080)
$Pass_1 = GUICtrlCreateInput("", 16, 80, 329, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
GUICtrlSetTip(-1, "Type password, or leve blank for non")
GUICtrlSetState(-1, $GUI_Focus)
GUICtrlSetColor(-1, 0xFF0000)
;GUICtrlSetOnEvent(-1, "Pass_1Change")
$Pass_2 = GUICtrlCreateInput("", 16, 128, 329, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
GUICtrlSetTip(-1, "Type password, or leve blank for non")
GUICtrlSetColor(-1, 0xFF0000)
;GUICtrlSetColor(-1, 0x00FF00)
;GUICtrlSetOnEvent(-1, "Pass_2Change")
$ALabel1 = GUICtrlCreateLabel("User Name", 16, 8, 64, 16)
$ALabel2 = GUICtrlCreateLabel("Password", 16, 64, 70, 16)
$ALabel3 = GUICtrlCreateLabel("Retype Password", 16, 112, 110, 16)
$OK = GUICtrlCreateButton("&Ok", 16, 160, 75, 25, $BS_DEFPUSHBUTTON)
GUICtrlSetOnEvent(-1, "OKClick")
GUICtrlSetTip(-1, "Enables Autologon")
$Exit = GUICtrlCreateButton("Exit", 104, 160, 75, 25, 0)
GUICtrlSetOnEvent(-1, "ExitClick")
GUICtrlSetTip(-1, "Exits Autologon")
$remowe = GUICtrlCreateButton("Remove", 272, 160, 75, 25, 0)
GUICtrlSetOnEvent(-1, "removeClick")
GUICtrlSetTip(-1, "Disables Autologon")
$Label1 = GUICtrlCreateLabel("©2007 //>Rex<\\", 256, 192, 91, 15)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
 Sleep(100)
 ; ==> Checking typed password
$Pass_Check =GUICtrlRead($Pass_1)
$Pass_Check2 = GUICtrlRead($Pass_2)
If $Pass_Check == $Pass_Check2 Then
GUICtrlSetColor($Pass_1, 0x00FF00) ; Sets the fontcolor to Green when the 2 passwords are identical
GUICtrlSetColor($Pass_2, 0x00FF00) ; Sets the fontcolor to Green when the 2 passwords are identical
Else
    GUICtrlSetColor($Pass_1, 0xFF0000) ; Sets fontcolor to Red, as default and until the 2 pass are identical
    GUICtrlSetColor($Pass_2, 0xFF0000) ; Sets fontcolor to Red, as default and until the 2 pass are identical
EndIf
; <== Checking typed password
WEnd

Func ExitClick()
SplashTextOn("By by","See u later aligator","350","50","-1","-1",2,"Arial Black","20","400")
Sleep(500)
Exit
EndFunc
Func OKClick()
    If $Pass_Check == $Pass_Check2 Then
    $Pass_Check_OK = $Pass_Check2
$regread = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LogonType"); Checks logon style in reg
If $regread = "00000001" Then; If Dword = 1 logon typpe is XP, and we changes it to oldstyle
RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "Background")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AllowMultipleTSSessions", "REG_DWORD", "00000000")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LogonType", "REG_DWORD", "00000000")
EndIf

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "ForceAutoLogon", "REG_SZ", "1")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon", "REG_SZ", "1")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword", "REG_SZ", $Pass_Check_OK)

MsgBox(64,"Autologon","Autologon for User " & @CRLF & @Username & @CRLF & "Is Enabled...",10)
    Else
MsgBox(16,"Password","Passwords" & @CRLF & "are not identical..." & @CRLF & "Try again.")
        GUICtrlSetData($Pass_1, "") ; Clear input
        GUICtrlSetData($Pass_2, "") ; Clear input
    EndIf
EndFunc

Func remoweClick()
    $Check = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "ForceAutoLogon")
        If $Check == "1" Then
$iMsgBoxAnswer = MsgBox(52,"Password","This will disable Autologon !" & @CRLF & @CRLF & "Do you want to disable Autologon ?")
Select
    Case $iMsgBoxAnswer = 6 ;Yes
    RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "ForceAutoLogon") ; This part enables Disables Autologon
    RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon") ; This part enables Disables Autologon
    RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword") ; This part enables Disables Autologon
    $iMsgBoxAnswer = MsgBox(64,"Autologon","Autologon for User" & @CRLF & @Username & @CRLF & "are dissabled...",10)
   Case $iMsgBoxAnswer = 7 ;No
EndSelect
Else
MsgBox(16,"Autologon","Autologon not aktiv" & @CRLF & "on this computer !!")
End
EndFunc

If txt don't fit in txt boxes it's becorse i translated directly in code :)

Edited by Rex

Share this post


Link to post
Share on other sites
Rex

So this logs the computer on at startup?

Yes and no

This sets som info in the registry, that enables the autologon function

/Rex

Share this post


Link to post
Share on other sites
MHz

Nice work. :)

I guess that this is similar to typing "Control Userpasswords2" in the run box and using the Gui to set passwords and logon?

Share this post


Link to post
Share on other sites
Rex

Nice work. :)

I guess that this is similar to typing "Control Userpasswords2" in the run box and using the Gui to set passwords and logon?

Don't know the func Control UserPass

I just converted a reg tweaki to a AutoIT gui controled reg tweaki :-)

/rex

Share this post


Link to post
Share on other sites
hum3

This is great.

I just corected a couple of typos so it runs and changed a message to one that was more neutral.

CODE
; Generated by NewScript 4.5

;----------------------------------------------------------------------------

; Created: 06-05-2007 13:02:23

; Author: Johnny Rex

; Mail: RexprivatAThotmailDOTcom

; Version: 1.0a

; AutoitVer: 3.1.1.119

; AutoItForum:

; Script Function:

; Enables or disables Auto logon on Wndows XP

; Changelog: 1.0a Hum3 2007-09-13 Corrected a couple of typos

;

; ----------------------------------------------------------------------------

#include <GUIConstants.au3> ; Includes GUIConstants.au3 to script

; Opt's Start > --------------------------------------------------------------

; Opt("RunErrorsFatal", 1) ;1=fatal, 0=silent set @error

Opt("GUIOnEventMode", 1) ;0=disabled, 1=OnEvent mode enabled

; Opt("GUICloseOnESC", 1) ;1=ESC closes, 0=ESC won't close

; Opt("TrayIconDebug", 0) ;0=no info, 1=debug line info

; Opt("TrayMenuMode",0) ;0=append, 1=no default menu, 2=no automatic check, 4=menuitemID not return

; Opt("TrayOnEventMode",0) ;0=disable, 1=enable

Opt("TrayIconHide", 1) ;0=show, 1=hide tray icon

; Opt("TrayAutoPause",1) ;0=no pause, 1=Pause

; Opt's End > ----------------------------------------------------------------

; Script start

Global $Pass_1, $Pass_2, $Pass_Check, $Pass_Check2, $Pass_Check_OK

#Region ### START Koda GUI section ###

$AutoLogon = GUICreate(" Force Autologon", 365, 208, -1, -1, BitOR($WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_BORDER, $WS_CLIPSIBLINGS))

$User_Name = GUICtrlCreateInput("", 16, 24, 329, 30, BitOR($ES_CENTER, $ES_AUTOHSCROLL, $ES_READONLY))

GUICtrlSetData(-1, @UserName)

;GUICtrlSetState(-1, $GUI_Disable)

GUICtrlSetFont(-1, 14, 400, 0, "Arial")

GUICtrlSetColor(-1, 0x800080)

$Pass_1 = GUICtrlCreateInput("", 16, 80, 329, 21, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL))

GUICtrlSetTip(-1, "Type password, or leve blank for non")

GUICtrlSetState(-1, $GUI_Focus)

GUICtrlSetColor(-1, 0xFF0000)

;GUICtrlSetOnEvent(-1, "Pass_1Change")

$Pass_2 = GUICtrlCreateInput("", 16, 128, 329, 21, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL))

GUICtrlSetTip(-1, "Type password, or leve blank for non")

GUICtrlSetColor(-1, 0xFF0000)

;GUICtrlSetColor(-1, 0x00FF00)

;GUICtrlSetOnEvent(-1, "Pass_2Change")

$ALabel1 = GUICtrlCreateLabel("User Name", 16, 8, 64, 16)

$ALabel2 = GUICtrlCreateLabel("Password", 16, 64, 70, 16)

$ALabel3 = GUICtrlCreateLabel("Retype Password", 16, 112, 110, 16)

$OK = GUICtrlCreateButton("&Ok", 16, 160, 75, 25, $BS_DEFPUSHBUTTON)

GUICtrlSetOnEvent(-1, "OKClick")

GUICtrlSetTip(-1, "Enables Autologon")

$Exit = GUICtrlCreateButton("Exit", 104, 160, 75, 25, 0)

GUICtrlSetOnEvent(-1, "ExitClick")

GUICtrlSetTip(-1, "Exits Autologon")

$remowe = GUICtrlCreateButton("Remove", 272, 160, 75, 25, 0)

GUICtrlSetOnEvent(-1, "removeClick")

GUICtrlSetTip(-1, "Disables Autologon")

$Label1 = GUICtrlCreateLabel("©2007 //>Rex<\\", 256, 192, 91, 15)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

Sleep(100)

; ==> Checking typed password

$Pass_Check = GUICtrlRead($Pass_1)

$Pass_Check2 = GUICtrlRead($Pass_2)

If $Pass_Check == $Pass_Check2 Then

GUICtrlSetColor($Pass_1, 0x00FF00) ; Sets the fontcolor to Green when the 2 passwords are identical

GUICtrlSetColor($Pass_2, 0x00FF00) ; Sets the fontcolor to Green when the 2 passwords are identical

Else

GUICtrlSetColor($Pass_1, 0xFF0000) ; Sets fontcolor to Red, as default and until the 2 pass are identical

GUICtrlSetColor($Pass_2, 0xFF0000) ; Sets fontcolor to Red, as default and until the 2 pass are identical

EndIf

; <== Checking typed password

WEnd

Func ExitClick()

SplashTextOn("By by", "On reboot will log on", "350", "50", "-1", "-1", 2, "Arial Black", "20", "400")

Sleep(500)

Exit

EndFunc ;==>ExitClick

Func OKClick()

If $Pass_Check == $Pass_Check2 Then

$Pass_Check_OK = $Pass_Check2

$regread = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LogonType"); Checks logon style in reg

If $regread = "00000001" Then; If Dword = 1 logon typpe is XP, and we changes it to oldstyle

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "Background")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AllowMultipleTSSessions", "REG_DWORD", "00000000")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LogonType", "REG_DWORD", "00000000")

EndIf

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "ForceAutoLogon", "REG_SZ", "1")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon", "REG_SZ", "1")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword", "REG_SZ", $Pass_Check_OK)

MsgBox(64, "Autologon", "Autologon for User " & @CRLF & @UserName & @CRLF & "Is Enabled...", 10)

Else

MsgBox(16, "Password", "Passwords" & @CRLF & "are not identical..." & @CRLF & "Try again.")

GUICtrlSetData($Pass_1, "") ; Clear input

GUICtrlSetData($Pass_2, "") ; Clear input

EndIf

EndFunc ;==>OKClick

Func RemoveClick()

$Check = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "ForceAutoLogon")

If $Check == "1" Then

$iMsgBoxAnswer = MsgBox(52, "Password", "This will disable Autologon !" & @CRLF & @CRLF & "Do you want to disable Autologon ?")

Select

Case $iMsgBoxAnswer = 6 ;Yes

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "ForceAutoLogon") ; This part enables Disables Autologon

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon") ; This part enables Disables Autologon

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword") ; This part enables Disables Autologon

$iMsgBoxAnswer = MsgBox(64, "Autologon", "Autologon for User" & @CRLF & @UserName & @CRLF & "are dissabled...", 10)

Case $iMsgBoxAnswer = 7 ;No

EndSelect

Else

MsgBox(16, "Autologon", "Autologon not active" & @CRLF & "on this computer !!")

End

EndIf

EndFunc ;==>removeClick

Share this post


Link to post
Share on other sites
Creator

Carefull with that!

The password is also stored in the following location HKLM\SECURITY\Policy\Secrets\DefaultPassword\CurrVal once you enable autologon.

Dont forget to delete that too. Or your password will be retrievable, since it is stored in plain text, even when autologon is disabled!

As mentioned, when autologon enabled, the password can be read in plain text in registry.

You can encrypt the autologon password by using the LsaStorePrivateData function in Advapi32.dll. Its designed specially for encrypting the autologon password.

http://msdn2.microsoft.com/en-us/library/ms721818.aspx the function

http://msdn2.microsoft.com/en-us/library/aa378826.aspx more information

Have fun!

and good luck

:)

Edited by Creator

Share this post


Link to post
Share on other sites
BullGates

I would not use RegDelete, since as default those keys exist on windows, instead I suggest you to set values back:

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "ForceAutoLogon", "REG_SZ", "0")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon", "REG_SZ", "0")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword", "REG_SZ", "")

[topic="51913"]Restrict USB Storage usage to group membership[/topic] * [topic="48699"]Using nircmd library[/topic] * Some admin notes

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×