Video Screencast Help

Ho to use DS System variables

Created: 29 Jan 2012 • Updated: 05 Sep 2012 | 5 comments
This issue has been solved. See solution.

Hi,

I've seen this post (which tells how to send job notification email)

also I've seen this list of system variables, but i didnt understand where these variables are located ?

on deployed machine ? or on the server side ?

 

I've being trying to execute #c code which actually uses those variables, by the next way :

 

StreamWriter sw = new StreamWriter("log.txt");
sw.WriteLine(Environment.ExpandEnvironmentVariables(@"%JOBNAME%"));
sw.Close();

but the output i get is just a %JOBNAME%...

if i use with system environment variables (%appdata%) for examp, everything works ...

 

 

any idea ?

 

thanks

Comments 5 CommentsJump to latest comment

bhawver's picture

Some variables are on the deployed machine and some will be ont he server itself.  The one that you are looking at above should be on the server.  In order to take advantage of that variable, the job will need to be run "Locally on the Deployment Server".

Brian Hawver
Systems Engineer
Yaskawa America, Inc.

Connect Etiquette: "Mark as Solution" those posts which resolve your problem, and give a thumbs up to useful comments, articles and downloads.

igal.ep's picture

i managed to work with those variables on deployed machine

by using batch file i wrote the variable value to txt file...

 

so why i cant use them in .Net code ?

ianatkin's picture

The way DS performs its replacement of these special variables like %JOBNAME% is to parse the scripts which are directly passed through the engine before executing.

Compiled code (like .NET) cannot have 'token replacement' function performed on it, as in order to do so the engine would have to decompile the code, replace the tokens and recompile before executing.

The way I get around this is to have my compiled code accept arguments, and have this executed by DS. For example,

 call mycode.exe %JOBNAME% %COMPNAME% 

Kind Regards,
Ian./

Ian Atkin, IT Services, Oxford University, UK

Connect Etiquette: "Mark as Solution" those posts which resolve your problem, and give a thumbs up to useful comments, articles and downloads

SOLUTION
igal.ep's picture

First, thanks for the reason explanation !

what i actually did is to wrote all relevant variables to text file (execution of batch file) and then i'm reading it from the compiled .Net, I have many of argument to pass :)

Gompie1403's picture

Or set the variables as environment variables in your embedded script before calling your script or executable:

set JOBNAME=%JOBNAME%
set COMPNAME=%NODEFULL%

cscript myscript.vbs

Note that these System tokens are always in uppercase.

These system tokens are replaced in the first script (in this case the embedded script) and are replaced not only with "Locally on the deployment server" but also on normal tasks.