Jump to content
DeployCentral

Auto Logon Once as Administrator after Deployment


lx.josh
 Share

Recommended Posts

Yeah it can. With SmartDeploy support help I managed to do it for me. Here are the steps you need to perform to make it work:

1. Create a vbs script and call it, for instance, autoadmin.vbs

2. The code is below:

UpdateXML "T:\windows\panther\unattend.xml"
UpdateXML "T:\windows\system32\sysprep\unattend.xml"


Sub UpdateXML(xmlFile)
        
	Set xmlUnattendFile = CreateObject("MSXML2.DOMDocument.6.0")
	xmlUnattendFile.Async = "False"
	blnLoaded = xmlUnattendFile.Load(xmlFile)

	If (blnLoaded) And (xmlUnattendFile.parseError.errorCode = 0) Then
		xmlUnattendFile.setProperty "SelectionNamespaces", "xmlns:ns='urn:schemas-microsoft-com:unattend'"
		Set objXmlNode = xmlUnattendFile.selectSingleNode("//ns:settings[@pass='oobeSystem']/ns:component[@name='Microsoft-Windows-Shell-Setup']")
		If Not (objXmlNode Is Nothing) Then
			'create the AutoLogon node
			Set objXmlElement = xmlUnattendFile.createNode(1, "AutoLogon", "urn:schemas-microsoft-com:unattend")
			objXmlNode.appendChild(objXmlElement)
			'select it
			Set objXmlNode = xmlUnattendFile.selectSingleNode("//ns:component[@name='Microsoft-Windows-Shell-Setup']/ns:AutoLogon")
			
			'create the Password node and elements
			Set objXmlElement = xmlUnattendFile.createNode(1, "Password", "urn:schemas-microsoft-com:unattend")
				objXmlNode.appendChild(objXmlElement)
			Set objXmlNode = xmlUnattendFile.selectSingleNode("//ns:AutoLogon/ns:Password")
			Set objXmlElement = xmlUnattendFile.createNode(1, "Value", "urn:schemas-microsoft-com:unattend")
                                'put your admins password below
				objXmlElement.Text = "PASSWORD_GOES_HERE"
				objXmlNode.appendChild(objXmlElement)
			Set objXmlElement = xmlUnattendFile.createNode(1, "PlainText", "urn:schemas-microsoft-com:unattend")
				objXmlElement.Text = "True"
				objXmlNode.appendChild(objXmlElement)
			
			'select the AutoLogon node and create elements			
			Set objXmlNode = xmlUnattendFile.selectSingleNode("//ns:component[@name='Microsoft-Windows-Shell-Setup']/ns:AutoLogon")
			Set objXmlElement = xmlUnattendFile.createNode(1, "Enabled", "urn:schemas-microsoft-com:unattend")
				objXmlElement.Text = "true"
				objXmlNode.appendChild(objXmlElement)
			Set objXmlElement = xmlUnattendFile.createNode(1, "LogonCount", "urn:schemas-microsoft-com:unattend")
                                'below put the number of how many times the account should log in automatically
				objXmlElement.Text = "1"
				objXmlNode.appendChild(objXmlElement)
			Set objXmlElement = xmlUnattendFile.createNode(1, "Username", "urn:schemas-microsoft-com:unattend")
                                'put the account name in you want to autologon
				objXmlElement.Text = "Administrator"
				objXmlNode.appendChild(objXmlElement)	

			'save it
	        	xmlUnattendFile.Save(xmlFile)
		End If
	End If
End Sub 

Make sure you set your admins password, logon count (how many times you want your admin acc to log on after consecutive logons and reboots) and the actual account name, which is administrator in the code but you can put another account if you have any.

3. When using Media Wizard, on the screen where you can select a folder with more files to attach to the image, browse to the folder where you put the autoadmin.vbs script so it gets copied over to the image.

IMPORTANT: If you are going to use the WDS deployment with PXE boot and your image will be a WIM image, not a ISO image, your files WILL NOT get copied over to the image (I hope admins will make sure they fix that so both ISO and WIM images are the same). In order to copy those files over to a WIM file, you will need to use IMAGEX.EXE program to mount, create folders and copy autoadmin.vbs script and commit changes to the WIM image. If you decide to go for that, let me know, I'll help you out.

4. Create a task in the deployment wizard and:

- set it as POSTIMAGE (after the image has been deployed)

- command line is: Wscript.exe X:\z\Scripts\autoadmin.vbs

If you wish to modify an existing answer file, just add the below lines:

<task>
<phase>POSTIMAGE</phase>
<command>Wscript.exe X:\z\scripts\autoadmin.vbs</command>
</task>

This worked for me. Hope it helps. Let me know if I can help you out more.

Jakub

Link to comment
Share on other sites

  • 2 years later...

Join the conversation

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

Guest
Reply to this topic...

×   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.

 Share

×
×
  • Create New...