Jump to content




Sign in to follow this  
anyweb

How can I pass values from the HTA to the Task Sequence



Recommended Posts

You can use your FrontEnd HTA to set values (variables) which in turn can be used (or checked for) in your Task Sequence. The FrontEnd can display options to your users like drop down menus or Radio Buttons, which have corresponding backend scripts which set values.

In addition, values can be gathered using the MDT ztigather.wsf script, this queries wmi and pulls a whole load of values which in turn are processed by ZTIUtility.vbs,

For example, the UUID value of a client is gathered (read) by ZTIgather.wsf, and ZTIutility.vbs sets this value oEnvironment.Item("UUID").

We can create a function in our HTA FrontEnd backend javascript script, to show the value of UUID.

function showUUID()
{
var oEnvironment = new ActiveXObject("Microsoft.SMS.TSEnvironment");
alert(oEnvironment("UUID"));
}

The script above will only work if a Gather step has taken place beforehand.

When ZtiGather.wsf runs, it produces a log file (ztigather.log) and in that log file you can see what it has detected, anything that is marked as Property can be ‘used’ or displayed in our HTA,

ztigatherlog.jpg



Javascript (*.js) backend sample

The below script will set a variable called DEPLOYMENTTYPE. It sets it to a value which in turn we'll check for in our task sequence.

var oEnvironment = new ActiveXObject("Microsoft.SMS.TSEnvironment");
oEnvironment("DEPLOYMENTTYPE") = "NEWCOMPUTER";

The task sequence has a Group which checks for the value of that variable and if=NEWCOMPUTER It does some actions.

deploymenttype equals newcomputer.jpg



windows Scripting File (*.wsf) backend sample

The below sample code sets a variable called ALLOWOSDBUILD, which is checked for in the task sequence, if the value=NO then the task sequence shutsdown the computer.

<job id="PromptForPassword">
<script language="VBScript" >
Dim env,oTSProgressUI,MyPass
Set env = CreateObject("Microsoft.SMS.TSEnvironment")
set oTSProgressUI = CreateObject("Microsoft.SMS.TSProgressUI")
oTSProgressUI.CloseProgressDialog()
env("ALLOWOSDBUILD") = "NO"
MyPass=Inputbox("Please enter the Password to start the OS Deployment")
If MyPass = "password" then
env("ALLOWOSDBUILD") = "YES"
End If
</script>
</job>

wsf sample.jpg

 

and below is a VBS example

set env = CreateObject ("Microsoft.SMS.TSEnvironment")
strTask = env("_SMSTSPackageName")

' log file to be used
strFile = "\\server\log$\" & strTask & ".txt"

the above writes out the Task Sequence name as the 'name' of the log file.

Share this post


Link to post
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


×