Jump to content


  • 0
Sumixam

Setting up Autologin at the end of SCCM OSD

Question

I have a Task Sequence in SCCM that is deploying my test image just fine, so all the basics work. Now I am trying to add in the steps unique to our environment.

 

The first thing I need to do is to set the machine up to restart and auto log in when the TS completes. The restart works fine, but the auto login doesn't

 

I used the autologin example from this post ("How can I capture Windows 7") as a model but I cannot get it to work.

 

Right now I have the following 2 steps at the very end of my Task Sequence:

1. Run the autologin package (from the post) that imports the Registry keys

2. Restart the computer (I changed this to manually run Shutdown as I know the "Restart Computer" task in MDT sets the machine up to autologin as the local admin, better safe than sorry)

 

When it runs I get a quick flash of an error about interactive logins are not enabled (or something similar, it flashes quickly) and then the system reboots. When it comes up I get the Crtl-Alt-Del to login screen. When I do CAD my user account is set to log in but I have to provide the password. The password is correct in the REG file, so that isn't it.

 

Has anyone gotten this to work? Am I in so deep that I'm missing something obvious?

 

Thanks

Share this post


Link to post
Share on other sites

Recommended Posts

  • 0

Hi I was able to get my TS to setup a win7 image that Auto logged in after it was finished.

 

In our enviroment we have some PCs that need to autologin for a certain group. All these PCs have the same username as the hostname so made it a bit easier for me but I can show you the scripts I placed in the TS to get it to work. All up it is 8 steps added to TS which doubles up the same thing but it works!

 

So here are my 8 scripts: (Red text is the parts you will need to modify for your unique set up)

 

Script 1 - %windir%\system32\reg.exe ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1 /f

 

Script 2 - %windir%\system32\reg.exe ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultDomainName /t REG_SZ /d <YOUR DOMAIN> /f

 

Script 3 - %windir%\system32\reg.exe ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d %computername% /f

 

Script 4 - %windir%\system32\reg.exe ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /t REG_SZ /d <YOUR PASSWORD> /f

 

Script 5 - %windir%\system32\reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Runonce" /v AUTOLOG1 /d "c:\windows\system32\reg.exe ADD """HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon""" /v AutoAdminLogon /t REG_SZ /d 1 /f" /f

 

Script 6 - %windir%\system32\reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Runonce" /v AUTOLOG2 /d "c:\windows\system32\reg.exe ADD """HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon""" /v DefaultDomainName /t REG_SZ /d <YOUR DOMAIN> /f" /f

 

Script 7 - %windir%\system32\reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Runonce" /v AUTOLOG3 /d "c:\windows\system32\reg.exe ADD """HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon""" /v DefaultUserName /t REG_SZ /d %computername% /f" /f

 

Script 8 - %windir%\system32\reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Runonce" /v AUTOLOG4 /d "c:\windows\system32\reg.exe ADD """HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon""" /v DefaultPassword /t REG_SZ /d <YOUR PASSWORD> /f" /f

 

So the first 4 lines add the autologin settings into the Registry and the last 4 set them up for the 1st login. Now becuase I have my TS doing alot of other things SCCM logs in the PC to do these tasks and that kicks off the runonce commands which then sets it up for the autologin.

 

So once my TS is all finished I am left with the Laptop/PC sitting on the Desktop logged in by the user for the 1st time.

 

Hope this helps anyone else with this. Added a screen shot of the autologin sequance to show that it is run over 8 steps.

 

Cheers,

post-21169-0-66254500-1378090416_thumb.jpg

Share this post


Link to post
Share on other sites

  • 0

I GOT IT WORKING FINALLY!

Functions:

1. account logs in

2. shortcut under startup runs the vb script

3. gpudpate is ran

4. the script deletes the shortcut and itself

5. system reboots

6. computer is left at ctrl+alt+del

 

SCCM 2012:

At first I tried to use a runonce registry entry line to do the gpupdate and a reboot, however after sccm releases the os the runonce lines are not ran until a actual user logs in and off once. To fix this we used the startup folder to call a script which does the runonce actions.

 

 

In Task Sequence the Last step is set to run this application, for me I used a detection method of the domain name reg key.

SCCM Package

1. create .bat or .vbs to do the following (not provided) to do the following

1. runs the autologin.vbs

2. copies or creates a updateandreboot.lnk to the C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\ which points to the updateandreboot.vbs

3. copies the updateandreboot.vbs to c:\windows\temp\

 

autologin.vbs

Const HKEY_CLASSES_ROOT  = &h80000000
Const HKEY_CURRENT_USER  = &h80000001
Const HKEY_LOCAL_MACHINE = &h80000002
Const HKEY_USERS         = &h80000003
Const HKEY_CURRENT_CONFIG= &h80000005
Const HKEY_DYN_DATA      = &h80000006

sUsername = "domainaccount"
sPassword = "yourdomainpassword"
sDomain = "yourdomain"

strRegKey = "Software\Microsoft\Windows NT\CurrentVersion\Winlogon\"

Write64BitRegistry "REG_SZ", HKEY_LOCAL_MACHINE, strRegKey, "AutoAdminLogon", "1"
Write64BitRegistry "REG_SZ", HKEY_LOCAL_MACHINE, strRegKey, "DefaultUserName", sUsername
Write64BitRegistry "REG_SZ", HKEY_LOCAL_MACHINE, strRegKey, "DefaultDomainName", strComputer
Write64BitRegistry "REG_SZ", HKEY_LOCAL_MACHINE, strRegKey, "DefaultPassword", sPassword
Write64BitRegistry "REG_SZ", HKEY_LOCAL_MACHINE, strRegKey, "DefaultDomainName", sDomain
Write64BitRegistry "REG_SZ", HKEY_LOCAL_MACHINE, strRegKey, "ForceAutoLogon", 1
Write64BitRegistry "REG_DWORD", HKEY_LOCAL_MACHINE, strRegKey, "AutoLogonCount", 1
Write64BitRegistry "REG_DWORD", HKEY_LOCAL_MACHINE, strRegKey, "DisableCAD", 1

Sub Write64BitRegistry (strRegType, strRootKey, strKey, strValueName, strValue)
Dim objCtx, objLocator, objReg, intReturnCode

Set objCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
objCtx.Add "__ProviderArchitecture", 64
Set objLocator = CreateObject("Wbemscripting.SWbemLocator")
Set objReg = objLocator.ConnectServer("", "root\default", "", "", , , , objCtx).Get("StdRegProv")

If Ucase(strRegType) = "KEY" Then
intReturnCode = objReg.CreateKey(strRootKey,strKey)
End If
If Ucase(strRegType) = "REG_DWORD" Then
intReturnCode = objReg.SetDWORDValue(strRootKey,strKey,strValueName,strValue)
End If
If Ucase(strRegType) = "REG_SZ" Then
intReturnCode = objReg.SetStringValue(strRootKey,strKey,strValueName,strValue)
End If
If Ucase(strRegType) = "REG_EXPAND_SZ" Then
intReturnCode = objReg.SetExpandedStringValue(strRootKey,strKey,strValueName,strValue)
End If
If Not intReturnCode = 0 Then
'Failed to set the registry entry
End If
End Sub









 

Create a Shortcut that calls the vbs called UpdateandReboot.lnk

 

 

UpdateandReboot.vbs

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = WScript.CreateObject("WScript.Shell")

'deletes the shortcut
objShell.Run "cmd /c del /q "&chr(34)&"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\UpdateandReboot.lnk"&chr(34), 0, True

'wscript.echo "cmd /c del /q "&chr(34)&"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\UpdateandReboot.lnk"&chr(34)

'runs gpupdate and reboots
objShell.Run "cmd /k gpupdate"&chr(38)&chr(38)&"shutdown -r -f -t 10", 0, True

'deletes itself
strScript = Wscript.ScriptFullName
objFSO.DeleteFile(strScript)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...



×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.