Working with environmental variables
The older version of Microsoft Dynamics NAV (version before 2013) has a built-in function called ENVIRON
that allows us to collect OS environmental information; unfortunately, it is not compatible with the RoleTailored client
. In this recipe, we will build a simple C# class that will help us to achieve the output given by the
ENVIRON
function.
How to do it...
To start, create a new
Class Library
project in Visual Studio.In the newly created class, create a new file with the following code:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Management; using System.Runtime.InteropServices; namespace RemoteSystemInfo { [ClassInterface(ClassInterfaceType.AutoDual)] [ProgId("RemoteSystemInfo")] [ComVisible(true)] public class RemoteSystemInfo { public string GetSysInfo(string machine, string variable) { ManagementObjectSearcher query = null; ManagementObjectCollection...