I some times run into problems while installing SW as a part of my Task Sequence.. Now don’t get me wrong, most times the apply  software works like a charm, and everything is installed without a glitch. But every now and then,  a piece of software comes along that just won’t install as part of the TS.

To name a couple of the more resent ones i encountered, there is Cisco VPN that has a tendency to cut the network connection for just a second during installation, making the TS fail, or Lenovo(IBM) Presentation Director,  that has to have an active desktop in order to install correctly.

Now what I do in these cases (or actually always), is to run a script in end of my TS that sets the computer to auto logon as administrator, and then run a different script that takes care of the installations. Ones the software has been installed the script calls shutdown.exe to restart the computer. By doing this I not only get an extra step in the deployment process, that is TS independent, I also make sure that the machine polices are updated (because of the extra boot)

So now to the Step by Step: Note i assume everybody uses MDT integration, and has made a Toolkit Package ( see this entry on this https://blog.ctglobalservices.com/osdeploy/creating-and-using-toolkit-package/)

1: Create the script(here called Finalize.wsf) that will take care of the auto logon an executions of SW script.

___________________________________________________________

<job id="Finalize">
<script language="VBScript" src="ZTIUtility.vbs"/>
<script language="VBScript">
‘ // ***************  Script Header ***************
‘ //
‘ // Purpose:   perform automatic logon with local administrator and run scripts
‘ //
‘ // Usage:     cscript Finalize.wsf
‘ //
‘ // Coretech History:
‘ // 1.0.0     Michael Petersen 24/06/2008  Created initial version.
‘ //
‘ // *************** End Header ***************

‘//—————————————————————————-
‘//
‘//  Global constant and variable declarations
‘//
‘//—————————————————————————-
Option Explicit
Dim iRetVal

Const WINLOGON = "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon"
Const RUN_ONCE = "HKLMSoftwareMicrosoftWindowsCurrentVersionRunOnce"

Dim sPostInstallFolder
Dim sAdministrator
Dim sPassword
Dim sDomain
Dim sFile
Dim sComputer
DIM sScriptRoot
Dim env

Set env = CreateObject("Microsoft.SMS.TSEnvironment")

sPassword = env("APW") ‘ APW is set on deployment collection and must be the local admin password. Can also be hardcoded here.
sAdministrator = "administrator"
sComputer = env("OSDcomputername")
sDomain = env("UserDomain")
sScriptRoot = env("ScriptRoot")

‘ Place to put the postinstallation script.
sPostInstallFolder = "c:windowstemp"

‘//—————————————————————————-
‘//  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()

On Error Resume Next

     iRetVal = Success

     ZTIProcess = iRetval
‘//—————————————————————————-
‘//  Copy Post script to disk, Update RunOnce and change login settings.
‘//—————————————————————————-
        For Each sFile in Array("PostInstall.vbs")
            If oFSO.FileExists(sScriptRoot & "" & sFile) then
                oLogging.CreateEntry "Copying " & sScriptRoot & "" & sFile & " to " & sPostInstallFolder & sFile, LogTypeInfo
                oFSO.CopyFile sScriptRoot & "" & sFile, sPostInstallFolder & sFile, true
                oLogging.CreateEntry "Updating RunOnce to" & RUN_ONCE  & sPostInstallFolder & sFile, LogTypeInfo
                oShell.RegWrite RUN_ONCE & sFile, sPostInstallFolder & sFile,"REG_SZ"
                ‘change login settings.
                oShell.RegWrite WINLOGON & "AutoAdminLogon", "1", "REG_SZ"
                oShell.RegWrite WINLOGON & "DefaultUserName", sAdministrator, "REG_SZ"
                oShell.RegWrite WINLOGON & "DefaultDomainName", sComputer, "REG_SZ"
                oShell.RegWrite WINLOGON & "DefaultPassword", sPassword, "REG_SZ"
                oShell.RegWrite WINLOGON & "AutoLogonCount", "1", "REG_DWORD"
                oShell.RegWrite WINLOGON & "DisableCAD", "1", "REG_DWORD"
                oLogging.CreateEntry "Made changes to Logon settings ", LogTypeInfo
            Else
                oLogging.CreateEntry "Unable to copy script " & sFile & " from " & sScriptRoot & " because it does not exist.", LogTypeInfo
            End If
        Next  �
        oLogging.CreateEntry oUtility.ScriptName & " COMPLETED.  Return Value = " & iRetVal, LogTypeInfo
End Function

</script>
</job>
_____________________________________________________________________

This script will look trough you Toolkit scripts folder and add all scripts defined in the array to RUN ONCE as well as copy them to the computer (in this case C:\windows\temp). It will the update the registry to do one administrative logon.

2. Create a script (here called Postinstall.vbs) to handle the software installation, and remember to have the script call SHOTDOWN.EXE as the final step. The script here checks if Presentation Director software is present, runs it, and then reboots the machine.

_____________________________________________________________________________

Set oShell = CreateObject("WScript.Shell")
Set oFso = CreateObject("Scripting.FileSystemObject") 

If oFso.FileExists("C:\drivers\ThinkVantage\PDIRECT.exe") Then
        oShell.Run "C:\drivers\ThinkVantage\PDIRECT.exe /s",0,true
End If 

oShell.Run "C:\Windows\system32\shutdown -r -f -c ""OS Deployment done, Performing final reboot..."" -t 5",1,False

________________________________________________________________________

The software you want to install must of cause be present on the computer. Remember that the TS has finished at this point and we can not access the sw trough the DP any more. You can either add the software using a Data Image which i will explain in my next post, have it present in your driver package, if you use the DriverPaths1 method https://blog.ctglobalservices.com/osdeploy/drivers/using-bddmdt-driverpaths1-in-sccm/, append it directly to the master image, or copy it during the TS.

3. Place both scripts Finalize.wsf and Postinstall.vbs in your toolkit script folder.

4.Add a step at the end of you task sequence to run the the Finalize.wsf script (Remember to put in a Toolkit step)

image image

Just type cscript.exe “%ScriptRoot%\Finalize.wsf” in a Run Command Line, and the Postinstall.vbs script should be run post TS.

____________________-