COMPUTERNAME through .NET Interop

Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
edited 2013-01-17 in NAV Three Tier
When the environment-variable "COMPUTERNAME" is retrieved using 'Windows Script Host Object Model'.WshShell, the warning "The server has requested to run Windows Script Host Shell Object on your client." is displayed.

If "COMPUTERNAME" is retrieved through .NET Interop, does this still issues a warning?

How does the .NET Interop code looks like, to retrieve this variable, using NAV 2009 R2?
No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)

Answers

  • deV.chdeV.ch Member Posts: 543
    Do you need the computername of the Service Tier or the Client?
    If you need it for the client, the warning still apears, at least if you don't change your ClientUserSettings.

    If you want the service tier name (you don't run the code on the server) then no user validation is required.

    There are serveral ways to do this. You can evaluate a Environment Variable text by using this method:
    http://msdn.microsoft.com/en-us/library/system.environment.expandenvironmentvariables.aspx

    Or you use "system.environment.machinename":
    http://msdn.microsoft.com/en-us/library/system.environment.machinename.aspx
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    I need to retrieve the client's COMPUTERNAME.

    If the warning still appears when using Interop code, then I stick with Automation. What setting can be modified in ClientUserSettings.config to avoid this warning?
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • yukonyukon Member Posts: 361
    Hi Luc Van Dyck
    I need to retrieve the client's COMPUTERNAME.

    If the warning still appears when using Interop code, then I stick with Automation. What setting can be modified in ClientUserSettings.config to avoid this warning?

    Please check at this post
    http://mibuso.com/forum/viewtopic.php?f=32&t=56039
    http://www.mibuso.com/forum/viewtopic.php?f=23&t=48217

    Regards,
    Yukon
    Make Simple & Easy
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Thank you all
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • cjeromecjerome Member Posts: 2
    If someone is still interested how the .Net code look likes in C/AL here is an example

    EXIT(SysEnv.GetEnvironmentVariable(property));

    where property is text for e.g can 'COMPUTERNAME'
    and SysEnv is variable of type DotNet and subtype
    System.Environment.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    Regards,
    Jerome Cader
Sign In or Register to comment.