Hi Dave,
Welcome to MSDN newsgroup. As for the retreveing sys environment
variables , I think the only means is using WMI, and in .NET the WMI apis
are under the
System.Management namespace, here are some good articles on WMI in .net:
http://www.c-sharpcorner.com/Code/2004/Sept/WMIPart1.asp
http://www.c-sharpcorner.com/Code/2004/Sept/WMIPart2.asp
#Remoting and Connection Options
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconremotingandconnect
ionoptions.asp?frame=true
Also, I've paste a piece of test code below for your reference, if you
still need any further info on WMI, I suggest that you also have a look in
the WMI newsgroup, you can find many resources or former threads discussing
such problem there:
==========================
static void GetSysInfo(string domain, string machine, string username,
string password)
{
ManagementObjectSearcher query = null;
ManagementObjectCollection queryCollection = null;
ConnectionOptions opt = new ConnectionOptions();
opt.Impersonation = ImpersonationLevel.Impersonate;
opt.EnablePrivileges = true;
opt.Username = username;
opt.Password = password;
try
{
ManagementPath p = new ManagementPath
("\\\\" +machine+ "\\root\\cimv2");
ManagementScope msc = new ManagementScope(p, opt);
SelectQuery q= new SelectQuery("Win32_Environment");
query = new ManagementObjectSearcher(msc, q, null);
queryCollection = query.Get();
Console.WriteLine(queryCollection.Count);
foreach (ManagementBaseObject envVar in queryCollection)
{
Console.WriteLine("System environment variable {0} = {1}",
envVar["Name"], envVar["VariableValue"]);
}
}
catch(ManagementException e)
{
Console.WriteLine(e.Message);
Environment.Exit(1);
}
catch(System.UnauthorizedAccessException e)
{
Console.WriteLine(e.Message);
Environment.Exit(1);
}
}
}
========================================
HTH. Thanks,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)