Skip to content

Commit

Permalink
Added Final Configuration for MDT
Browse files Browse the repository at this point in the history
  • Loading branch information
arwidmark committed Jan 6, 2020
1 parent 9139bd5 commit 72cb7a3
Show file tree
Hide file tree
Showing 3 changed files with 275 additions and 0 deletions.
113 changes: 113 additions & 0 deletions Scripts/Final Configuration 2013/Configure-FinalConfig.wsf
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<job id="Configure-FinalCleanup">
<script language="VBScript" src="..\..\scripts\ZTIUtility.vbs"/>
<script language="VBScript">

'//----------------------------------------------------------------------------
'// Solution: Hydration
'// Purpose: Used to do some custom configuration after task sequence completes
'// Usage: cscript Configure-FinalConfig.wsf [/debug:true]
'// Version: 1.5 - January 5, 2020 - Johan Arwidmark
'//
'// This script is provided "AS IS" with no warranties, confers no rights and
'// is not supported by the authors or Deployment Artist.
'//
'//----------------------------------------------------------------------------

'//
'// Global constant and variable declarations
'//
'//----------------------------------------------------------------------------

Option Explicit
Dim iRetVal

'//----------------------------------------------------------------------------
'// End declarations
'//----------------------------------------------------------------------------

'//----------------------------------------------------------------------------
'// Main routine
'//----------------------------------------------------------------------------

'On Error Resume Next
iRetVal = ZTIProcess
ProcessResults iRetVal
On Error Goto 0

'//---------------------------------------------------------------------------
'//
'// Function: ZTIProcess()
'//
'// Input: None
'//
'// Return: Success - 0
'// Failure - non-zero
'//
'// Purpose: Perform main ZTI processing
'//
'//---------------------------------------------------------------------------

Function ZTIProcess()
iRetVal = Success
ZTIProcess = iRetval

Dim sSName,sCMD,sReturn,iZTIRetValue,sDomain,sFile,sTemporaryFolder,f

sSName=oUtility.ScriptName
'set the return value to assume a failure
iZTIRetValue="1"

'Start logging for this script
oLogging.CreateEntry sSName & ": Starting actions*********************************************************",LogTypeInfo

' Check for SkipFinalSummary value being set to YES
If UCASE(oEnvironment.Item("SkipFinalSummary")) = "YES" Then
oLogging.CreateEntry sSName & "SkipFinalSummary set to YES, continuing",LogTypeInfo
Else
oLogging.CreateEntry sSName & "SkipFinalSummary not set to YES, aborting",LogTypeError
ZTIProcess = Failure
Exit Function
End if

'Copying script to local machine, temp folder
Const TemporaryFolder = 2
Set sTemporaryFolder = oFSO.GetSpecialFolder(TemporaryFolder)
sFile = oUtility.ScriptDir & "\FinalConfig.hta"
oFSO.GetFile(sFile).Copy sTemporaryFolder & "\" & oFSO.GetFileName(sFile),True
sFile = oUtility.ScriptDir & "\Servers.png"
oFSO.GetFile(sFile).Copy sTemporaryFolder & "\" & oFSO.GetFileName(sFile),True
sFile = oEnvironment.Item("DEPLOYROOT") & "\Scripts\Wizard.ico"
oFSO.GetFile(sFile).Copy sTemporaryFolder & "\" & oFSO.GetFileName(sFile),True
sFile = oEnvironment.Item("DEPLOYROOT") & "\Scripts\Wizard.css"
oFSO.GetFile(sFile).Copy sTemporaryFolder & "\" & oFSO.GetFileName(sFile),True

'Create the cmd to start the HTA
sDomain = oEnvironment.Item("JOINDOMAIN")
sCmd="mshta.exe """ & sTemporaryFolder & "\FinalConfig.hta"" " & Chr(34) & sDomain & Chr(34)

'Log the cmd we are going to run
oLogging.CreateEntry "About to run " & sCmd,LogTypeInfo

'start the HTA, but don't wait for it to complete - otherwise well never end the TS.
oShell.CurrentDirectory = sTemporaryFolder
sReturn=oShell.run (sCmd,1,False)

'Log the return code from starting the HTA
oLogging.CreateEntry "Return code from " & sCMD & " was : " & sReturn,LogTypeInfo

'End Logging for this script
oLogging.CreateEntry sSName & ": Completed actions *********************************************************",LogTypeInfo

If sReturn="0" Then
iZTIRetValue = Success
oLogging.CreateEntry "HTA was started succesfully",LogTypeInfo
Else
iZTIRetValue = Failure
oLogging.CreateEntry "HTA failed to start",LogTypeError
End If

ZTIProcess=iZTIRetvalue
End Function

</script>
</job>
162 changes: 162 additions & 0 deletions Scripts/Final Configuration 2013/FinalConfig.hta
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
<html>
<head>
<title>Final Configuration</title>

<link href="Wizard.css" type="text/css" rel="stylesheet">

<HTA:APPLICATION ID="oFinalConfig"
APPLICATIONNAME="Final Configuration"
ICON="Wizard.ico"
SCROLL="no"
SELECTION="no"
INNERBORDER="no"
BORDER="normal"
SINGLEINSTANCE="no"
SYSMENU="no"
MAXIMIZEBUTTON="no"
MINIMIZEBUTTON="no"
/>

<script language="vbscript" type="text/vbscript">
<!--

Dim iTimerID
Dim stmp,iCount,bfound

Sub Window_onload
on error resume Next
CenterWindow 640,640
stmp=0
StatusArea.InnerHTML="Checking for Task Sequence process....<br><br>"
TestProcess
End Sub

Sub CenterWindow( widthX, heightY )
self.ResizeTo widthX, heightY
self.MoveTo (screen.Width - widthX)/2, (screen.Height - heightY)/2
End Sub

Function TestProcess()
Dim objWMIService, colProcess
Dim strComputer,objProcess
window.clearInterval(iTimerID)
strComputer = "."
stmp=stmp+1
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process WHERE name like 'TS%'")
bFound=1
For Each objProcess in colProcess
If UCase(objProcess.Name)="TSMANAGER.EXE" Then
bfound=0
End If
Next
If bFound=0 Then
StatusArea.InnerHTML="Task Sequencer is still Running. <BR> Pass " & stmp
TestProcess=0
Else
bfound=1
TestProcess=1
End If

iCount=0
iTimerID = window.setInterval("Progress",1000)

End Function

Function Progress()

If iCount<20 And bfound = 0 Then
CountArea.InnerHTML="Checking again in " & 20-iCount
iCount=iCount+1
Else
iCount=0
sTP=TestProcess()
If sTP=1 Then
CountArea.InnerHTML=""
window.clearInterval(iTimerID)

StatusArea.InnerHTML="Task Sequence process terminated, waiting 30 more seconds for LTICleanup.wsf to complete..."

iTimerID = window.setInterval("Configuration",30000)

Exit Function
End If
End If
End Function

Function Configuration()

Set oShell = CreateObject ("WScript.shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")

' Clean up any existing C:\MININT directory
StatusArea.InnerHTML=""
StatusArea.InnerHTML=StatusArea.InnerHTML & "<BR>" & "Clean up any existing C:\MININT directory"
If oFSO.FolderExists("C:\MININT") then
On Error Resume Next
oFSO.DeleteFolder "C:\MININT", true
StatusArea.InnerHTML=StatusArea.InnerHTML & "<BR>" & "C:\MININT directory deleted"
On Error Goto 0
End if

' Clean up any existing C:\_SMSTaskSequence directory
StatusArea.InnerHTML=""
StatusArea.InnerHTML=StatusArea.InnerHTML & "<BR>" & "Clean up any existing C:\_SMSTaskSequence directory"
If oFSO.FolderExists("C:\_SMSTaskSequence") then
On Error Resume Next
oFSO.DeleteFolder "C:\_SMSTaskSequence", true
StatusArea.InnerHTML=StatusArea.InnerHTML & "<BR>" & "C:\_SMSTaskSequence directory deleted"
On Error Goto 0
End if

' Enable autologon for another user account (comment out these lines)
' StatusArea.InnerHTML=StatusArea.InnerHTML & "<BR>" & "Enable autologon for another user account."
' oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoAdminLogon", 1, "REG_SZ"
' oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoLogonCount", 999, "REG_SZ"
' oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName", "Johan", "REG_SZ"
' oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName", "VIAMONSTRA", "REG_SZ"
' oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultPassword", "P@ssw0rd", "REG_SZ"
' oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\ForceAutoLogon", 1, "REG_SZ"
' oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DisableCAD", 1, "REG_DWORD"
' Disable Microsoft Security Essentials Setup Wizard (if machine was sysprepped with MSE installed)
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Security Client\OOBE", 0, "REG_DWORD"

' Reboot the client
StatusArea.InnerHTML=StatusArea.InnerHTML & "<BR>" & "Configuration Complete, rebooting client in 30 seconds... "
oShell.run "shutdown /f /r /t 30",1,False

End Function

Sub CloseWindow
self.close()
End Sub

-->
</script>

</head>

<body Language="VBScript" background=Servers.png>

<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr valign="top">
<td width="10"></td>
<td>
<H1><br>Final Configuration Utility for MDT 2013 Lite Touch</H1>
<span style="width: 95%;">
<table cellpadding="0" cellspacing="0" border="0">
<tr>Status:<br><br>
<td colspan="2" id="StatusArea"></td>
</tr>
<tr>
<td colspan="2" id="CountArea"></td>
</tr>
</table>
</span>
</td>
</tr>
</table>
</body>
</html>

Binary file added Scripts/Final Configuration 2013/Servers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 72cb7a3

Please sign in to comment.