MDT Task Sequence Hangs when using Terminal app

Task Sequence hangs (waits) installing an application until the mouse is clicked.

Adding the below PowerShell script to the start of the MDT deployment will force the client to use the old-school text window instead of the modern Windows Terminal app. It is often used by system builders to fix script errors or script frezzing.

Write-Host "Set the default terminal app to Console Host"
# This prevents scripts from unexpectedly aborting when/if the Terminal App gets updated while they are running. This may also prevent the rare, random problem of MDT Application installation PowerShell scripts not launching until mouse activity is detected.

New-Item -Path "HKCU:\Console" -Name "%%Startup" -ErrorAction Ignore | Out-Null

Set-ItemProperty -Path "HKCU:\Console\%%Startup" -Name "DelegationConsole" -Value "{B23D10C0-E52E-411E-9D5B-C09FDF709C7D}" -Type String

Set-ItemProperty -Path "HKCU:\Console\%%Startup" -Name "DelegationTerminal" -Value "{B23D10C0-E52E-411E-9D5B-C09FDF709C7D}" -Type String

Script source –
Task Sequence hangs (waits) installing an application until I move the mouse or click : r/MDT

Remove OneDrive via Batch Script

I’ve used this batch script to remove OneDrive from Windows 10 20H2 clients used by students. The script has been added to the end of our MDT student deployment.

@echo off
REM Prevents all commands from being displayed including ‘echo off’

set x86=”%SYSTEMROOT%\System32\OneDriveSetup.exe”
set x64=”%SYSTEMROOT%\SysWOW64\OneDriveSetup.exe”
REM Specifies environment-variables named x86 & x64.

taskkill /f /im OneDrive.exe > NUL 2>&1
REM Forcefully terminate the process using the image name ‘OneDrive.exe’.
REM ‘NUL 2>&1’ suppress outputs and pipe errors to null.

ping 127.0.0.1 -n 5 > NUL 2>&1
REM Misuse the ping command to delay commands, ‘-n 5’ specifies 5 pings. There is a 1s delay between each ping.

if exist %x64% (
%x64% /uninstall
) else (
%x86% /uninstall
)
REM Use the ‘if exist’ condition to uninstall both 32bit & 64bit versions of OneDrive.

ping 127.0.0.1 -n 10 > NUL 2>&1
REM Misuse the ping command to delay commands, ‘-n 10’ specifies 10 pings.

rd “%USERPROFILE%\OneDrive” /Q /S > NUL 2>&1
rd “C:\OneDriveTemp” /Q /S > NUL 2>&1
rd “%LOCALAPPDATA%\Microsoft\OneDrive” /Q /S > NUL 2>&1
rd “%PROGRAMDATA%\Microsoft OneDrive” /Q /S > NUL 2>&1
REM Remove OneDrive remnants. Delete directories and directory trees silently.

REG DELETE “HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}” /f > NUL 2>&1
REG DELETE “HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}” /f > NUL 2>&1
REM Remove OneDrive from File Explorer. Delete registry values without any confirmation prompt.

exit /b 0
REM Specifies to exit the current batch script. The numeric number specifies the process exit code.  Exit code is required for MDT deployment to finish without errors.

SIMS Installation – Batch File

For this installation package, the SIMS setup folder was copied to a network share on the MDT server.

net use X: \\MDT_SERVER\networkpackages$

start /wait X:\sims\setups\simsinfrastructuresetup.exe -a {QuietMode} {SIMSWorkstation} {FMSWorkstation}

start /wait X:\sims\setups\simsapplicationsetup.exe /S {QuietMode} [SIMSDirectory]="S:\SIMS" [SIMSDotNetDirectory]="C:\Program Files\SIMS\SIMS .net"

start /wait X:\sims\setups\simsmanualsetup.exe /S {QuietMode} [SIMSDirectory]="S:\SIMS" [SIMSDotNetDirectory]="C:\Program Files\SIMS\SIMS .net"

start /wait X:\sims\setups\simsamparksetup.exe /S {QuietMode} [SIMSDirectory]="S:\SIMS" [SIMSDotNetDirectory]="C:\Program Files\SIMS\SIMS .net"

echo SIMSSetupsDirectory=S:\SIMS\Setups >> C:\Windows\sims.ini

echo Folder=SIMS Applications >> C:\Windows\sims.ini

echo [SIMSConnection] >> "C:\Program Files\SIMS\SIMS .net\connect.ini"

echo REDIRECT=S:\SIMS >> "C:\Program Files\SIMS\SIMS .net\connect.ini"

net use /delete /y X:

DisplayLink Installation – Batch File

The registry edits changes the default behaviour of connected displays from extended to mirrored mode. The listed msi is only suitable for Windows 7 to Windows 10 1511.

start /wait msiexec /i "DisplayLink_Win7-10TH2.msi" /quiet /norestart
 
reg add HKEY_LOCAL_MACHINE\SOFTWARE\DisplayLink\Products\DefaultProduct\OnNewDevice /v Activity /t REG_SZ /d Mirror /f

reg add HKEY_LOCAL_MACHINE\SOFTWARE\DisplayLink\Products\DisplayLink Graphics\OnNewDevice /v Activity /t REG_SZ /d Mirror /f