Getting Environment Variables from both server and client

rocatisrocatis Member Posts: 163
edited 2012-10-24 in NAV Three Tier
In NAV 2009 you had the option of creating automations on either the server side or the client side.

Thus,

CREATE(WSHShell,FALSE,TRUE);
MESSAGE('%1',WSHShell.ExpandEnvironmentStrings('%temp%'));

would give me the temp variable for the client, while

CREATE(WSHShell,FALSE,FALSE);
MESSAGE('%1',WSHShell.ExpandEnvironmentStrings('%temp%'));

would give me the temp variable for the server.

(WSHShell points to the automation 'Windows Script Host Object Model'.WshShell).

In NAV 2013 the last CREATE parameter must be TRUE which leads me to the question:

How do I reestablish the functionality I had before? How do I get the environment variable as seen from the server side?
Brian Rocatis
Senior NAV Developer
Elbek & Vejrup

Comments

  • stomdahlstomdahl Member, Microsoft Employee Posts: 12
    You can use DotNet interop instead, runs both client and server side.

    Name DataType Subtype
    environment DotNet System.Environment.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

    MESSAGE('%1',environment.GetEnvironmentVariable('temp'));
  • rocatisrocatis Member Posts: 163
    stomdahl wrote:
    MESSAGE('%1',environment.GetEnvironmentVariable('temp'));
    That's definitely what I'm looking for, but the "old" automation actually converts a whole string containing environment variables. Something like

    environment.InsertEnvironmentVariables('%temp%\User\file%username%') returning 'C:\Users\BROCAT~1\AppData\Local\Temp\User\fileBRocatis3101'. I can't seem to find anything like that in DotNet (which doesn't exactly lack options).

    Guess I'll have to write a parser myself. Thanks for putting me on the right path.
    Brian Rocatis
    Senior NAV Developer
    Elbek & Vejrup
  • deV.chdeV.ch Member Posts: 543
    Have a look at this: http://www.dotnetperls.com/environment
    See under: ExpandEnvironmentVariables

    It does exactly what you want.
Sign In or Register to comment.