Page 1 of 1

XP Autologin

Posted: Wed Sep 13, 2006 9:01 pm
by NoahPhense
Does anyone have some code that will setup an auto login for xp?

- np

Posted: Wed Sep 13, 2006 9:12 pm
by KarLKoX

Posted: Wed Sep 13, 2006 9:37 pm
by Droopy

Posted: Thu Sep 14, 2006 2:55 am
by NoahPhense
These are both excellent references. Here's what I'm looking to do. I
have a system at work that I'm testing this on. But more importantly.
If this works well, it will be pushed out and auto-executed globally to
2 to 3 systems per location.

Do you think I can use these references to make a single executable that
when launched from the administrators profile, or with the administrators
credentials. It can set these systems into auto login mode?

- np

Posted: Thu Sep 14, 2006 12:43 pm
by thefool
i really can't see why you wouldnt be able to do that..
look at the references!

Posted: Thu Sep 14, 2006 3:03 pm
by NoahPhense
thefool wrote:i really can't see why you wouldnt be able to do that..
look at the references!
That wasn't really a contribution.. ;)

I am a bit scidish about the reference on MS that shows how to do this.

But it only talks about the account that you want to autolog, being an
administrator account.

Well, I don't want an administrator account to autolog, I want a regular
user account to autolog.

*EDIT* .. I got something working.. I'll post later.

- np

Posted: Thu Sep 14, 2006 4:53 pm
by KarLKoX
LogonUser is not administror specific, it is up to you to choose who do you want to log as specified in the param, then, you should use ImpersonateLoggedOnUser with the value returned by LogonUser.

Posted: Thu Sep 14, 2006 8:43 pm
by Droopy
It's easy with admin rights and purebasic to write to registry. ( write values to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon : DefaultUserName / DefaultPassword / AutoAdminLogon ...

Posted: Thu Sep 14, 2006 8:45 pm
by Edwin Knoppert
sysinternals has tool.

Posted: Fri Sep 15, 2006 11:58 am
by NoahPhense
Droopy wrote:It's easy with admin rights and purebasic to write to registry. ( write values to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon : DefaultUserName / DefaultPassword / AutoAdminLogon ...
I've done this. But have experienced a major security issue. After I've
edited the registry settings. You cannot log into the system via RA
anymore. I know, wierd.

And to add to that pain, the auto log didn't work.

Keep in mind that the computer is on a domain. But the account that
I'm having auto log is a local account to the machine.

- np

Posted: Fri Sep 15, 2006 10:03 pm
by Droopy
You can autologon to a domain with the 'DefaultDomainName' value.

See here : http://www.winguides.com/registry/display.php/13/

..

Posted: Fri Sep 15, 2006 11:29 pm
by NoahPhense
Hey Droopy..

Yeah I have that. But it still didn't work. There must be something else
junked up on these systems. I even thoguht it might be the legal notice,
but as you can see I cleared those out. Hmm..

Code: Select all

; KAR Repair Utility
; by (removed)

Declare.s ReadRegKey(OpenKey.l, SubKey.s, ValueName.s)
Declare.l WriteRegKey(OpenKey.l, SubKey.s, KeySet.s, KeyValue.s)

Define.l key1, key2, key3, key4, key5, key6, key7, key8

start.s = InputRequester("KIOSK AUTO-LOGON REPAIR", "Type " + Chr(34) + "yes" + Chr(34) + " to proceed.", "")

If LCase(start) = "yes"
  If InitNetwork()
    DefaultDomain.s = Hostname()
    key1 = WriteRegKey(#HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName",    "kiosk")
    key2 = WriteRegKey(#HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword",    "")
    key3 = WriteRegKey(#HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultDomain",      DefaultDomain) 
    key4 = WriteRegKey(#HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "CachePrimaryDomain", DefaultDomain) 
    key5 = WriteRegKey(#HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon",     "1") 
    key6 = WriteRegKey(#HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "ForceAutoLogon",     "1") 
    key7 = WriteRegKey(#HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LegalNoticeCaption", "") 
    key8 = WriteRegKey(#HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LegalNoticeText",    "") 
  Else
    MessageRequester("HostName Issue ..", "HostName Not Found -- please enter it in the next window.")
    DefaultDomain.s = InputRequester("Enter HostName", "i.e. MIAMBKI967391 (don't forget the KI)","")
    key1 = WriteRegKey(#HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName",    "kiosk")
    key2 = WriteRegKey(#HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword",    "")
    key3 = WriteRegKey(#HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultDomain",      DefaultDomain) 
    key4 = WriteRegKey(#HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "CachePrimaryDomain", DefaultDomain) 
    key5 = WriteRegKey(#HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon",     "1") 
    key6 = WriteRegKey(#HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "ForceAutoLogon",     "1") 
    key7 = WriteRegKey(#HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LegalNoticeCaption", "") 
    key8 = WriteRegKey(#HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LegalNoticeText",    "") 
  EndIf

  If key1 And key2 And key3 And key4 And key5 And key6 And key7 And key8
    MessageRequester("Success!", "All registry keys were correctly modified.", #MB_ICONINFORMATION)
  EndIf
Else
  ; do nothing
EndIf

MessageRequester("K.A.R. - Kiosk Auto-Logon Repair", "© (removed) International // coded by (removed)")

End


;- Procedures

; read a key from the registry 
Procedure.s ReadRegKey(OpenKey.l, SubKey.s, ValueName.s) 
  hKey.l = 0 
  KeyValue.s = Space(255) 
  Datasize.l = 255 
  If RegOpenKeyEx_(OpenKey, SubKey, 0, #KEY_READ, @hKey) 
    KeyValue = "Error Opening Key" 
  Else 
    If RegQueryValueEx_(hKey, ValueName, 0, 0, @KeyValue, @Datasize) 
      KeyValue = "Error Reading Key" 
    Else  
      KeyValue = Left(KeyValue, Datasize - 1) 
    EndIf 
    RegCloseKey_(hKey) 
  EndIf 
  ProcedureReturn KeyValue 
EndProcedure 

;write a key to the registry 
Procedure.l WriteRegKey(OpenKey.l, SubKey.s, KeySet.s, KeyValue.s) 
  hKey.l = 0  
  If RegCreateKey_(OpenKey, SubKey, @hKey) = 0 
    Result = 1 
    Datasize.l = Len(KeyValue) 
    If RegSetValueEx_(hKey, KeySet, 0, #REG_SZ, @KeyValue, Datasize) = 0 
      Result = 2 
    EndIf 
    RegCloseKey_(hKey) 
  EndIf 
  ProcedureReturn Result 
EndProcedure
- np

Posted: Tue Sep 26, 2006 1:28 am
by ConsoleMan
I haven't used PureBasic yet... Window shopping :D

But make sure you are setting all these values:

AutoAdminLogon
ForceAutoLogon
DefaultUserName
AltDefaultUserName
DefaultPassword
DefaultDomainName
AltDefaultDomainName

And LegalNotice/Logon Banner text won't stop it from working. To bypass the autlogon and get the prompt (for when you logon), hold down the shift key.

I do this sort of thing remotely in batch files using reg.exe i.e.

reg add "\\%strRemoteHostname%\HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v ForceAutoLogon /t REG_SZ /d 1 /f

Posted: Tue Sep 26, 2006 3:18 am
by Rogue
Edwin suggested a Sysinternals tools but didn't say which one. Here is a link to the program which may solve your problem:

http://www.sysinternals.com/Utilities/PsExec.html

It is very powerful and will allow you to run an app on a remote system with whatever credentials are needed.

Posted: Tue Sep 26, 2006 5:35 am
by ConsoleMan
psexec along with the other pstools are great, but he specifically wanted autologon... And you don't need 3rd party utils (or even PB) to make it happen local or remote.