XP Autologin

Everything else that doesn't fall into one of the other PB categories.
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

XP Autologin

Post by NoahPhense »

Does anyone have some code that will setup an auto login for xp?

- np
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post by KarLKoX »

"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Post by Droopy »

User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Post 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
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

i really can't see why you wouldnt be able to do that..
look at the references!
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Post 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
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post 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.
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Post 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 ...
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

sysinternals has tool.
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Post 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
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Post by Droopy »

You can autologon to a domain with the 'DefaultDomainName' value.

See here : http://www.winguides.com/registry/display.php/13/
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

..

Post 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
ConsoleMan
New User
New User
Posts: 8
Joined: Tue Aug 15, 2006 4:38 pm

Post 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
Rogue
User
User
Posts: 10
Joined: Wed Jul 09, 2003 12:27 pm
Location: Michigan

Post 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.
Where ever you go, there you are.
ConsoleMan
New User
New User
Posts: 8
Joined: Tue Aug 15, 2006 4:38 pm

Post 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.
Post Reply