HTA

OSD Options Chooser v3

Posted on Updated on

The following custom HTA can be used during OSD when imaging computers with ConfigMgr.  It has been updated from my previous version and will do the following:

Remember to enable HTA support in your boot images – https://t3chn1ck.wordpress.com/2010/01/28/hta-support-in-sccm-boot-images/

OSDOptionsV3

<!--
Created by Nick Moseley https://t3chn1ck.wordpress.com
For this script to function, HTA support must have been added into the boot image
See for more information - http://technet.microsoft.com/en-us/library/dd799244.aspx

This HTA/VBscript is used to present a GUI during imaging of a corporate PC. It prompts for:
	1) PC name (automatically populated if the PC already exists in SCCM)
	2) Time zone (currently just PST, AZT, and MST)
	3) If the PC will be used as a VM parent image or as a physical PC
	4) One-off software
	5) Additional browsers
	6) Department selection
	7) Management selection
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>OSD Computer Details</title>
<HTA:APPLICATION ID="objNoTitleBar" APPLICATIONNAME="OSD Computer Details" SCROLL="auto" SINGLEINSTANCE="yes" CAPTION="no">

<script language="VBScript">
window.resizeTo 550,255
window.moveTo 3,3

' Hide the task sequence window
'On Error Resume Next

Dim oTaskSequence, oTSProgressUI
Set oTaskSequence = CreateObject ("Microsoft.SMS.TSEnvironment")
Set oTSProgressUI = CreateObject("Microsoft.SMS.TsProgressUI")
oTSProgressUI.CloseProgressDialog

Sub PreloadOptions
	Dim sTSMachineName, bPromptName
	sTSMachineName = ucase(oTaskSequence("_SMSTSMachineName"))

	If left(sTSMachineName,6) = "MININT" Then
		bPromptName = True
	ElseIf sTSMachineName = "MINWINPC" Then
		bPromptName = True
	Else
		bPromptName = False
	End If

	If bPromptName Then
		ComputerName.value = ""
	Else
		ComputerName.value = sTSMachineName
	End If
End Sub

Sub FinishClickTasks
	'====================================
	' Get/set computer name
	'====================================
	Dim sComputerName
	sComputerName = UCase(ComputerName.Value)

	' Check that a PC name was entered
	Do
		If sComputerName = "" Then
			MsgBox "Error: Computer name cannot be left empty!", vbCritical, "Error"
			sComputerName = InputBox ("Please enter a computer name to continue", "", , 30,30)
		End If
	Loop Until sComputerName <> ""

	oTaskSequence ("OSDComputerName") = sComputerName

	'====================================
	' Get/set department configuration
	'====================================
	For Each oSelection in DepartmentChooser.Options
		If oSelection.Selected Then
			oTaskSequence ("OSDDepartment") = lcase(oSelection.InnerText)
		End If
	Next

	'====================================
	' Get/set managerial position
	'====================================
	For Each oSelection in ManagerRole.Options
		If oSelection.Selected Then
			oTaskSequence ("ManagerRole") = lcase(oSelection.InnerText)
		End If
	Next

	'====================================
	' OSConfig selection
	'====================================
	For Each oSelection in OSConfig
		If oSelection.Checked Then
			oTaskSequence ("OSDOSConfig") = lcase(oSelection.value)
		End If
	Next

	'====================================
	' Get/set Other Apps
	'====================================
	If SevenZip.checked Then oTaskSequence ("OSD7zip") = "true" End If
	If Firefox.checked Then oTaskSequence ("OSDFirefox") = "true" End If
	If NotepadPlusPlus.checked Then oTaskSequence ("OSDNotepadPlusPlus") = "true" End If
	If GoogleChrome.checked Then oTaskSequence ("OSDGoogleChrome") = "true" End If
	If PaintNet.checked Then oTaskSequence ("OSDPaintNet") = "true" End If
	If Safari.checked Then oTaskSequence ("OSDAppleSafari") = "true" End If

	'====================================
	' Get/set Time Zone configuration
	'====================================
	For Each oSelection in TZChooser.Options
		If oSelection.Selected Then
			oTaskSequence ("OSDTimeZone") = oSelection.id
		End If
	Next

	'====================================
	' Terminate the HTA
	'====================================
	window.close
End Sub

</script>
</head>

<!------------------------------------------------>
<!---------------- HTML goes here ---------------->
<!------------------------------------------------>
<body STYLE="font:12 pt arial; color:white; background-color:#006699" onload="PreloadOptions">
<table cellpadding="3" border=1>
	<tr valign=top>
		<td>
			<p>
			<b>Computer Name</b><br>
			<input type=text id="ComputerName" name=ComputerName size=22>
			<p>
			<b>Time Zone</b><br>
			<select size="1" name="TZChooser">
				<option value="00" id="Mountain Standard Time">MST (US Mountain)<BR>
				<option value="01" id="Pacific Standard Time">PST (US West Coast)<BR>
				<option value="02" id="US Mountain Standard Time">AZT (US Arizona)<br>
				<!--<option value="03" id="Central Standard Time">CST (US Central)<BR>-->
				<!--<option value="04" id="Eastern Standard Time">EST (US East Coast)<BR>-->
			</select>
			<p>
			<b><u>OS Configuration</b></u><br>
			<input type="radio" value="standalone" name="OSConfig" checked="True"> Standalone PC/VM<br>
			<input type="radio" value="vmparent" name="OSConfig"> VM Parent
		</td>
		<td>
			<b><u>Software Options</b></u><br>
			<input type="checkbox" name="SevenZip"> 7-zip Utility<br>
			<input type="checkbox" name="NotepadPlusPlus"> Notepad++<br>
			<input type="checkbox" name="PaintNet"> Paint.Net<br>
			<p>
			<b><u>Internet Browsers</b></u><br>
			<input type="checkbox" name="Safari"> Apple Safari<br>
			<input type="checkbox" name="Firefox"> Firefox Browser<br>
			<input type="checkbox" name="GoogleChrome"> Google Chrome<br>
		</td>
		<td>
			<p>
			<b><u>Department Selection</b></u><br>
			<select size="1" name="DepartmentChooser">
				<option value="00"> Standard PC</option>
				<option value="01"> Accounting</option>
				<option value="02"> Human Resources</option>
				<option value="03"> Information Technology</option>
			</select>
			<p>
			<b><u>Management Role</b></u><br>
			<select size="1" name="ManagerRole">
				<option value="00"> n/a</option>
				<option value="01"> Supervisor</option>
				<option value="02"> Manager</option>
				<option value="03"> Director</option>
				<option value="03"> VP</option>
			</select>
			<p>
			<button accesskey=N type=submit id=buttonFinish onclick=FinishClickTasks>Finish</button>
		</td>
	</tr>
</table>
<!------------------------------------------------>
<!------------------ End HTML -------------------->
<!------------------------------------------------>

</body>
</html>

Displaying Front-End HTAs within a SCCM Task Sequence

Posted on Updated on

I’ve often heard the phrase “MDT solves problems to issues you didn’t even know you had.”  And it’s certainly true in this case!!

I was  looking for a process or procedure that would allow me to present my current custom OSD front end HTA to an active end-user who is logged into Windows.  Unfortunately, standard SCCM task sequences don’t allow this to happen.  To workaround this, my first consideration was to run the HTA as a prerequisite of the task sequence, but therein lay another issue with SCCM task sequences – since the HTA was run as a prerequisite Program, it was not technically within the Task Sequence environment and therefore I could not set task sequence variables, etc.

Fortunately the good folks on the MyITForum discussion list were able to steer me in the right direction.  MDT 2010 Update 1 contains a standalone executable (ServiceUI.exe) that allows execution of anything (not just an HTA) within a task sequence and enables the end-user to interact with it.  To utilize ServiceUI without integrating MDT with SCCM, perform the following:

  1. Install MDT 2010 Update 1 on your local computer
  2. Find ServiceUI.exe (for the appropriate target architecture) and put it into the same directory as your HTA front end script(s)
  3. Create a script that will
    a)  Make a copy of the HTA on the local executing computer (only if your advertisement is set to “run from server”)
    b)  Run command: ServiceUI.exe -session:1 %WINDIR%\system32\mshta.exe C:\CustomSystemOptions.hta

    1. Note 1: it’s important to know that the options “-session:1” will only work if the user logged into Windows has local admin rights.  My suggestion is to restart Windows and login as the local Administrator account.
    2. Note 2: Thanks to Ryan for feedback that when running on a 64-bit system, use %WINDIR%\SYSWOW64\mshta.exe
      The exception to this note is if you’re using SCCM 2012 … then it must use mshta.exe from System32.
  4. Update your task sequence to include a “Run Command Line” as the very first item in the task sequence
    a)  Name it something like “Service UI – Custom System Options”
    b)  Set the command line as “TheNameOfYourScript.vbs”
    c)  Use the package which contains your scripts
    d)  CRITICAL: Do not set option “Time-out (minutes)” as this will cause ServiceUI to error!
    e)  On the Options tab, add a condition to check that TS variable “_SMSTSInWinPE” = false

In short, this should be all that you need to get going to display the HTA to end-user.  However, the thing that I do not yet have resolved in this all this is that when connected to a system through RDP, ServiceUI will launch the HTA, but it’s not displayed.  Still gotta figure that one out….and then update this post of course ;-)

OSD Options Chooser v2

Posted on Updated on

Attention – this Options Chooser has been superseded by Nick’s “version 3” which can be reviewed at https://t3chn1ck.wordpress.com/2013/06/06/osd-options-chooser-v3/

The following custom HTA can be used during OSD when imaging computers with SCCM 2007.  It has been updated from my previous version and will do the following:

  • Section 1 – for the name to be give to the computer.
  • Section 2 – for the technician imaging the computer
  • Section 3 – for a ticket number
  • Section 4 – for adding a user to the local admins group
  • Section 5 – for selecting the computer’s time zone
    Note: additional time zones can be found at http://technet.microsoft.com/en-us/library/cc749073(WS.10).aspx
  • Section 6 – for selecting a flavor of Acrobat as post installed software
  • Section 7 – for selecting other software to be installed
    Note that on the first three sections, if the option is left empty, then after clicking finish a circular prompt is done until a value is added.  Also, they set custom Task Sequence variables which you will need to use later in your process, such as in custom logging or setting a registry key for your organization, etc.

Also, remember to enable HTA support in your boot images – https://t3chn1ck.wordpress.com/2010/01/28/hta-support-in-sccm-boot-images/

<!-- ----------------------------------------------------------- Created by Nick Moseley https://t3chn1ck.wordpress.com For this script to function, HTA support must have been added into the boot image See for more information - http://technet.microsoft.com/en-us/library/dd799244.aspx --------------------------------------------------------------- -->



OSD Options Chooser


<script type="text/vbscript" language="vbscript">// <![CDATA[
window.resizeTo 375,700
window.moveTo 5,5

Sub FinishClickTasks
'On Error Resume Next
Dim oTaskSequence, oShell, sComputerName, bErrComputerName, bErrTechName, bErrTicketNumber, sCurPath, sKioskName
Set oTaskSequence = CreateObject ("Microsoft.SMS.TSEnvironment")
Set oShell = CreateObject ("WScript.Shell")
sComputerName = UCase(ComputerName.Value)

' Set values inputed from HTA dialog
If sComputerName = "" Then
oTaskSequence ("OSDComputerName") = "null"
Else
oTaskSequence ("OSDComputerName") = sComputerName
End If

If TechName.Value = "" Then
oTaskSequence ("OSDTechName") = "null"
Else
oTaskSequence ("OSDTechName") = TechName.Value
End If
If TicketNumber.Value = "" Then
oTaskSequence ("OSDTicketNumber") = "null"
Else
oTaskSequence ("OSDTicketNumber") = TicketNumber.Value
End If

' Check for errors with the computer name or technician name
Dim sTSVar1, sTSVar2, sTSVar3, bNoErr
sTSVar1 = oTaskSequence("OSDComputerName")
sTSVar2 = oTaskSequence("OSDTechName")
sTSVar3 = oTaskSequence("OSDTicketNumber")
bNoErr = False

If sTSVar1 = "null" Then
bErrComputerName = True
End If
If sTSVar2 = "null" Then
bErrTechName = True
End If
If sTSVar3 = "null" Then
bErrTicketNumber = True
End If

' Display error message
If bErrComputerName And bErrTechName And bErrTicketNumber Then
MsgBox "Error: Computer name, technician name, and Incident or Service Request number cannot be blank.", vbCritical, "Error"
ElseIf bErrComputerName And bErrTechName Then
MsgBox "Error: Computer name and technician name cannot be blank.", vbCritical, "Error"
ElseIf bErrComputerName And bErrTicketNumber Then
MsgBox "Error: Computer name and Incident or Service Request number cannot be blank.", vbCritical, "Error"
ElseIf bErrTechName And bErrTicketNumber Then
MsgBox "Error: Technician name and Incident or Service Request number cannot be blank.", vbCritical, "Error"
ElseIf bErrComputerName Then
MsgBox "Error: Computer name cannot be blank.", vbCritical, "Error"
ElseIf bErrTechName Then
MsgBox "Error: Technician name cannot be blank.", vbCritical, "Error"
ElseIf bErrTicketNumber Then
MsgBox "Error: Incident or Service Request number cannot be blank.", vbCritical, "Error"
End If 

' Loop until end-user enters a value
Do 
If bErrComputerName Then
sComputerName = InputBox ("Please enter a COMPUTER name to continue", "", , 30,30)
If sComputerName <> "" Then
oTaskSequence ("OSDComputerName") = sComputerName
bErrComputerName = False
End If
ElseIf bErrTechName Then
sTechName = InputBox ("Please enter a TECHNICIAN name to continue.", "", , 30,30)
If sTechName <> "" Then 
oTaskSequence ("OSDTechName") = sTechName
bErrTechName = False
End If
ElseIf bErrTicketNumber Then
sTicketNumber = InputBox ("Please enter an Incident or Service Request number to continue.", "", , 30,30)
If sTicketNumber <> "" Then 
oTaskSequence ("OSDTicketNumber") = sTicketNumber
bErrTicketNumber = False
End If
Else
bNoErr = True
End If
Loop Until  bNoErr

' Set local time zone
For Each oTimeZone In TimeZone
If oTimeZone.Checked Then
oTaskSequence("OSDTimeZone") = oTimeZone.value
End If
Next

' UserName to add as a local administrator
If UserName.Value <> "" Then 
oTaskSequence ("OSDAdminUser") = UserName.Value
End If

' Applications to install
' Acrobat
If Acrobat(1).checked Then
oTaskSequence ("OSDAcrobat10") = "standard"
ElseIf Acrobat(2).checked Then
oTaskSequence ("OSDAcrobat10") = "professional"
End If

' Other Apps
If ProjectStd2010.checked Then
oTaskSequence ("OSDProjStd2010") = "true"
End If
If VisioStd2010.checked Then
oTaskSequence ("OSDVisioStd2010") = "true"
End If
If StreetsTrips2010.checked Then
oTaskSequence ("OSDStreetsTrips2010") = "true"
End If

window.close
End Sub
// ]]></script>

<!-- HTML goes here -->


Computer Name

<input id="ComputerName" type="text" name="ComputerName" size="45" />

Technician Name Imaging Computer

<input id="TechName" type="text" name="TechName" size="45" />

Incident or Request Number

<input id="TicketNumber" type="text" name="TicketNumber" size="45" />

Username to add to Local Admin Group (if applicable)

<input id="UserName" type="text" name="UserName" size="45" />

<b>Select Time Zone For the Computer</b>

<input type="radio" name="TimeZone" value="Pacific Standard Time" />PST (US West Coast)

<input type="radio" name="TimeZone" value="US Mountain Standard Time" />AZT (US Arizona)

<input type="radio" name="TimeZone" value="Mountain Standard Time" />MST (US Mountain)

<input type="radio" name="TimeZone" value="Central Standard Time" />CST (US Central)

<input type="radio" name="TimeZone" value="Eastern Standard Time" />EST (US East Coast)


<b>Select Post Installed Applications</b>

<input type="radio" name="Acrobat" /> Do not install Acrobat

<input type="radio" name="Acrobat" /> Adobe Acrobat Standard X

<input type="radio" name="Acrobat" /> Adobe Acrobat Professional X



<input type="checkbox" name="ProjectStd2010" /> Microsoft Project Standard 2010

<input type="checkbox" name="StreetsTrips2010" /> Microsoft Streets and Trips 2010

<input type="checkbox" name="VisioStd2010" /> Microsoft Visio Standard 2010


<button accesskey="N" id="buttonFinish" onclick="FinishClickTasks" type="submit">Finish</button>

Created by Nick Moseley, https://t3chn1ck.wordpress.com


HTA Support in SCCM Boot Images

Posted on Updated on

Want to have HTA support in your SCCM 2007 SP2 boot images (with WinPE 3.0), but don’t want to implement MDT 2010?  Follow these short instructions to get yourself on your way!  When doing this for the first time, I recommend using a copy of the boot.wim and not your production boot.wim!!

The general process for doing this:

  1. Ensure you have installed the WAIK for Windows 7
  2. Mount the base image by using the DISM tool to a local directory share. For example,
    Dism /Mount-Wim /WimFile:C:\winpe_x86\winpe.wim /index:1 /MountDir:C:\winpe_x86\mount
  3. Add packages, and language packs as appropriate by using the Dism command with the /Add-Package option. For example, to add the HTA package you must add both the language neutral package along with the language specific package. For example:
    Dism /image:C:\winpe_x86\mount /Add-Package /PackagePath:”C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\WinPE-HTA.cab”

     Dism /image:C:\winpe_x86\mount /Add-Package /PackagePath:”C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\en-us\WinPE-HTA_en-us.cab”
  4. Commit the changes using the Dism command with the /Unmount-Wim /Commit option. For example,
     Dism /Unmount-Wim /MountDir:C:\winpe_x86\mount /Commit
  5. Import the .wim into SCCM and, voila, you now have a boot image with HTA support!

Reference: http://technet.microsoft.com/en-us/library/dd799244.aspx

HTA BackEnd Script for OSD

Posted on Updated on

This post has been updated with new code. 

Please visit OSD Options Chooser v2

There are plenty of examples out there for how to get the most out of Task Sequences for SCCM 2007 OS deployment.  But I wasn’t motivated to find out how others were doing it…Until I saw a demonstration by Jarvis Davis that he presented at MMS 2009. 

From that I built my own custom HTML Application to do what I needed.  At the moment, I have not enabled HTA support in my WinPE boot images.  So the below example is purely a “BackEnd” script which simply means that it needs to run at the towards the end of the Task Sequence so that the end-operator (or end-user) does not need to wait for much of the imaging to complete.

This HTA does the following

  • Field to enter in the name of user to add into the local Administrators group
  • Selection for US time zone to configure Windows to use (defaults to MST, since that is where I am)
  • Option to install one of 6 flavors of Adobe Acrobat
  • Option to install one of 2 flavors of Project 2003
  • Option to install one of 2 flavors of Visio 2003
  • Option to install BlackBerry desktop
  • Option to install Streets and Trips 2006

Additional things to note

  • In order to add a domain user to your local admins group, the value sDomainName = “YourDomainName” must be filled in appropriately.
  • All activity is logged into C:\CustomSystemOptions.log
  • If one of the options to install software is selected, a Task Sequence variable is created and set to True.  To utilize this, you would need to have an Install Software task that is limited to only install of the corresponding variable is set to True.  Note: the Install Software task must be after the execution of the HTA!