Jump to content


  • 0
pvr02

Prestart HTA to pick Task Sequence

Question

I am attempting to create an HTA that runs in the prestart context of a boot image. It has a prompt for computername, drop down for Operating System (task sequence), and a check box to run updates during OSD. However, when it runs, It still prompts me to pick a task sequence immediately following the HTA prompt. Can anyone point me in the right direction where my mistake is?

<html>
<head>

<title>Centered HTA</title>

<HTA:APPLICATION 
     ID="objHTA"
     APPLICATIONNAME="OSD Computer Details"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     CAPTION="no"
     showInTaskbar="no"
     sysMenu="no"
     contextMenu="no"
     border="none"
     borderStyle="sunken"
>
</head>

<SCRIPT Language="VBScript">
    Sub Window_Onload
        strComputer = "."
        Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
        Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
        For Each objItem in colItems
            intHorizontal = objItem.ScreenWidth
            intVertical = objItem.ScreenHeight
        Next
        intLeft = (intHorizontal - 400) / 2
        intTop = (intVertical - 300) / 2
        window.resizeTo 400,300
        window.moveTo intLeft, intTop
    End Sub

'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 os configuration
    '====================================
    For Each oSelection in osChooser.Options
        If oSelection.Selected Then
            oTaskSequence ("SMSTSPreferredAdvertID") = ucase(oSelection.InnerText)
        End If
    Next

    '====================================
    ' Get/set Updates
    '====================================
    If UpdateCheckbox.checked Then oTaskSequence ("OSDUpdates") = "true" End If 

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

</SCRIPT>

<body></body>

<body STYLE="font:12 pt arial; color:white; background-color:#0434b2" onload="PreloadOptions">
<div style="text-align:center"> 
<img style="width: 261px; height: 86px; border: 0;" src="logo.png"> 
</div>
<p>
<table align="center" cellpadding="3" border=1>
    <tr valign=top>
        <td align="center">
            <p>
            <b>Computer Name</b><br>
            <input type=text id="ComputerName" name=ComputerName size=22>
        </td>
        <td align="center">
            <p>
            <b>OS Selection</b><br>
            <select size="1" name="OSChooser">
                <option value="SMS00026"> Windows 7 x86</option>
                <option value="SMS00027"> Windows 8.1 x64</option>
                <option value="SMS00054"> Windows 10 x64</option>
            </select>
            <p>
        </td>
    </tr>
</table>
<p>
<div style="text-align:center">            
<input type="checkbox" name="UpdateCheckbox" checked="true"> Apply Updates During Build
</div>
<p>
<div style="text-align:center">            
<button accesskey=N type=submit id=buttonFinish onclick=FinishClickTasks>Finish</button>
</div>
</html>

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

did you verify this works ? is the task sequence in question deployed as hidden ?

oTaskSequence ("SMSTSPreferredAdvertID") = ucase(oSelection.InnerText)

what does the smsts.log reveal ?

Share this post


Link to post
Share on other sites

  • 0

The task sequences are not hidden and are all visable.

 

The smsts.log file had the following message: "Provided preferred deployment WINDOWS 7 X86 is not found among the available deployments".

 

Turns out to be a 2 part problem.

  1. I was using the Package ID of the task sequence instead of the Deployment ID. (This has been resolved)
  2. Under the value options in the drop down it is passing "Windows 7 x86" instead of SMS00026 to the variable. I am trying to figure out why this is happening now.

Share this post


Link to post
Share on other sites

Join the conversation

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

Guest
Answer this question...

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

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.