Sign in to follow this  
Followers 0
EirikB

Auto login Windows 7 Question

5 posts in this topic

Hello everyone,

First off, I want to thank everyone that has worked on autoit for the great job, and also all the contributors :oops:

I have been using autoit for some time now, and I'm starting to get into it quite nicely.

I have been using it for everything from reg hacking, to putting up shortcuts, wmi querys, questionnaire, information gathering and so on.

I was however recently struggling with a little "issue", I've made myself a little mix of a powershell and autoit script, to take computer’s out of the domain, rename them, and put them back in again (due to a failure in name standards).

Now for this, I needed to activate auto-login for the computers.

First off I tried the autologin from pstools, but it worked only when it felt like it, (iow: first PC it worked, second pc it did not work and so on)

I then tried to use the following:

<p>
$hostname = @ComputerName
$auser = "LOCAL_ADMIN"
$apass = "SOMEPASSWORD"

regwrite("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName", "REG_SZ", $auser)
regwrite("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword","REG_SZ", $apass)
regwrite("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultDomain", "REG_SZ", $hostname)
regwrite("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon", "REG_SZ", "1")

</p><p></p>

(I use the $hostname = @ComputerName just since I like to keep the scripts that way, no other reason :doh: )

Anyways, this did not work properly, and it did not login automatically on reboot.

I then went on to call a powershell script using a normal run("") and Set-ItemPropery to set the same variables.

This worked..

Could anyone explain why it did not work from autoit, but it works from powershell?

I got it working for me, so it’s not a problem, it’s just a little annoying, and I like to understand what is wrong, or what I'm doing wrong.

Extra info:

OS: Windows 7 SP1 - English x64

Code compiled using x64. (tried x86 and also tried using HKLM64 instead, and compile it as x86 as well as x64 to test it)

.exe File is deployed through SCCM, and using fileinstall to copy the .ps1 file to the computer, then delete it after its done.

Every other part of the autoit script works properly + setting a lot of registry strings and reporting some information to a central info database, so it remembers the name for next time, and does not mix up the names.

Reason for powershell in the picture, is also just since it's a lot easier to work with in regards to leaving domains/renaming/re-joining domains.

I am not worried about the password being in clear text, as i lock the computer at once when the login starts during these phases, and the script cleans it up afterwards.

Anyways, would be nice if anyone has any idea why it fails.

Thanks again everyone :bye:

Best Regards:

Eirik aka Xandor

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I have two possibilities in my mind:

1) try to compile it as 32bit, add this at top of your script and compile it from full Scite4Autoit3 by F7

#AutoIt3Wrapper_UseX64=n ;(Y/N) Use X64 versions for AutoIt3_x64 or AUT2EXE_x64. Default=N

2) try to change privilegies of your script

#AutoIt3Wrapper_res_requestedExecutionLevel=requireAdministrator

EDIT: Also check if registry are changed after you run your script.

Edited by Zedna

Share this post


Link to post
Share on other sites

I had a similar issue before. Add this to your script with the other RegWrite calls.

RegWrite("HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogon", "ForceAutoLogon", "REG_SZ", "1")

Be sure to set it back to "0", when you clear your auto logon.

Adam

Share this post


Link to post
Share on other sites

Adam:

Tried that one, it still only works when it feels like it.

Zedna:

I'm not sure what the Wrapper_useX64 is for, will check that one up :oops:

I see I forgot to add that i am running it with the #requireadmin, and deploying it using SCCM, so it runs as Local System, to prevent UAC from interfering, and make sure it gets highest access available. :bye:

So i dont think the requestedExecutionLevel will change to much there, or am i way off? :doh:

Did some testing last night..

Put it in a separate script now and tried to run it multiple times, seems it "forgets" to put the password in now and then :-s

Ran it 15 times in a row now (deleted the strings between every run), and it "forgot" the Password field 6 times of those 15..

My general tests have been performed on a number of diffrent models (Fujitsu, Lenovo, HP, Acer), so its not a problem with one type either.

I also use diffrent installation media/types/lisenses on them, so its not a OS setup problem either ;)

//Xan

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Try these other registry keys, it would cover all the bases that I can think of.

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AltDefaultUserName", "REG_SZ", $sUserName)
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AltDefaultDomainName", "REG_SZ", $sDomain)


Here is a function that I use, that hasn't caused me any issues. Hope it helps.

Func _AutoLogon($iOnOff, $sUserName, $sPassword, $sDomain, $iForceAutoLogon = 0)
If $iOnOff = 0 Then ;Auto Logon OFF.
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon", "REG_SZ", "0")
Else ;Auto Logon ON. If $iOnOff is anything but 0, it is set to 1 (ON).
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsof\tWindows NT\CurrentVersion\Winlogon", "AutoAdminLogon", "REG_SZ", "1")
EndIf

If $iForceAutoLogon = 1 Then ;Force Auto Logon ON.
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "ForceAutoLogon", "REG_SZ", "1")
Else  ;Force Auto Logon OFF. If $iForceAutoLogon is anything but 1, it is set to 0 (OFF).
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "ForceAutoLogon", "REG_SZ", "0")
EndIf

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName", "REG_SZ", $sUserName)
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AltDefaultUserName", "REG_SZ", $sUserName)
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword", "REG_SZ", $sPassword)
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultDomainName", "REG_SZ", $sDomain)
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AltDefaultDomainName", "REG_SZ", $sDomain)

EndFunc   ;==>_AutoLogon

Also, use IsAdmin to check to see if you are running with the admin token.


Adam

Edited by AdamUL

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  
Followers 0