ラース、あなたが以前言ったことと似たようなことを読んだことがあります。残念ながら、問題のマシンでできることはいくらか制限されています (つまり、ユーザー グループを勝手に作成することはできません。これはサーバーであり、ランダムな PC ではありません)。
答えてくれてありがとう、ウィルとラース。残念ながら、彼らは私の問題を解決しませんでした。
これに対する究極の解決策は、WMI を使用することです。
using System.Management;
String queryString = "select CreationDate from Win32_Process where ProcessId='" + ProcessId + "'";
SelectQuery query = new SelectQuery(queryString);
ManagementScope scope = new System.Management.ManagementScope(@"\\.\root\CIMV2");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection processes = searcher.Get();
//... snip ... logic to figure out which of the processes in the collection is the right one goes here
DateTime startTime = ManagementDateTimeConverter.ToDateTime(processes[0]["CreationDate"].ToString());
TimeSpan uptime = DateTime.Now.Subtract(startTime);
この一部は Code Project からスクレイピングされました。
http://www.codeproject.com/KB/system/win32processusingwmi.aspx
そして、「Hey, Scripting Guy!」:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/jul05/hey0720.mspx