Deployment Solution

 View Only
  • 1.  Ho to use DS System variables

    Posted Jan 29, 2012 06:07 AM

    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



  • 2.  RE: Ho to use DS System variables

    Posted Jan 30, 2012 08:43 AM

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



  • 3.  RE: Ho to use DS System variables

    Posted Feb 02, 2012 07:16 AM

    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 ?



  • 4.  RE: Ho to use DS System variables
    Best Answer

    Trusted Advisor
    Posted Feb 04, 2012 04:47 PM

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



  • 5.  RE: Ho to use DS System variables

    Posted Feb 05, 2012 10:34 AM

    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 :)



  • 6.  RE: Ho to use DS System variables

    Posted Apr 04, 2012 08:21 AM

    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.