Video Screencast Help
Search Video Help Close Back
to help
New in the Rewards Catalog: Vouchers for "Symantec Technical Specialist" and "Symantec Certified Specialist" exams.

How to Get Computername and Guid in Workflow

Updated: 10 Oct 2009 | 5 comments
claus66's picture
+3 3 Votes
Login to vote

There's been a few post about retrieving host computername in a Workflow. Here's how I do it:

A little javascript to access the Altiris.SWRAgentUtils which - as I understand it - is used by the Softwareportal (http://<ns-server>/Altiris/SWD/SoftwarePortal.aspx)

I have a form with two textboxes named txt1 and txt2 ( to name a control 'Edit Component -> Functionality tab', check 'Specify Control ID' and type Control ID below)

controlID.JPG

Add the following code to the form: 'Edit form -> Behavior -tab -> Script - click the elipse(...):

script.JPG

function getPCinfo(){
var objAltiris = new ActiveXObject("Altiris.SWRAgentUtils");
var PCinfo = objAltiris.getMachineInfo();
var PCname = PCinfo.MachineName;
var PCguid = PCinfo.MachineGuid;
document.getElementById('txt1').value= PCname;
document.getElementById('txt2').value= PCguid;
 }

In the Body Custom Events click Add -> AttrubutesKeyValuePair
In the event-dropdown choose 'onload' and in the Eventhandler type:

getPCinfo()

tab.JPG
You're now set to go - click OK and test away.
I'm no javascript-wiz so the script may not work in non-IE enviroments.

 

Comments

lone_ranger's picture
12
Oct
2009
0 Votes 0
Login to vote

Thanks for the post

Thanks for the post claus66,

I'm working on doing exactly this, but I'm fairly new to the product and would appreciate as much information as possible. I see that you are editing a component in the screen shots but what component are you editing? Also, how do you tie this into a variable?

claus66's picture
13
Oct
2009
0 Votes 0
Login to vote

Hi Ranger The textboxes both

Hi Ranger

The textboxes both have Outputnames - without an Outputname you can't add the textbox to your form.
These Outputnames will be the variables that can be accessed later in the workflow.

The first screenshot is from one of the Textboxcomponent  (to access the Edit Component dialog just double-click the textbox ).
The next two screenshots are both from the webform-component (double-click an empty spot on your form)

Hope it helps

lone_ranger's picture
23
Nov
2009
0 Votes 0
Login to vote

Thanks claus66

Thanks for the reply,
I've been meaning to reply back. I made those changed and everything is working! Thanks again for the post.

ROO's picture
08
Jun
2010
0 Votes 0
Login to vote

Top of the Morning Great

Top of the Morning

Great stuff....works like a charm...much thanks

ChrisBern's picture
03
Sep
2010
0 Votes 0
Login to vote

A simple variation using WMI

If you don't have Altiris.SWRAgentUtils available, you can also get the computer name directly via WMI.  Follow claus66's suggestions exactly, except replace the Script with the following:

function getPCinfo(){

var ax = new ActiveXObject("WScript.Network");
document.getElementById('txt1').value=(ax.ComputerName);

 }

Important note:  any time you are running JavaScript as a client-side script, the script will only work if the browser settings allow for it.  The above script only worked for me once I backed down my IE security options in Tools / Internet Options / Security (I basically enabled several items in there that were previously disabled).  The caveat therefore is your end-users will need to have similarly accomodative browser settings, or else the script will not run.  So your level of control over the end-user's browser security is paramount to success, which is why client-side scripting is better off avoided if possible.