Quantcast
Channel: Task Scheduler Managed Wrapper
Viewing all articles
Browse latest Browse all 2206

New Post: Is there a way to find the logged in user's "domain\name" when creating a task in code running as SYSTEM?

$
0
0
That did create the task but then ran the process launched by the task as SYSTEM, not user. So I was back to square 1! Here's the way to get the username during install as a SYSTEM:
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT UserName FROM Win32_ComputerSystem");
ManagementObjectCollection collection = searcher.Get();
string username = (string)collection.Cast<ManagementBaseObject>().First()["UserName"];
 MessageBox.Show(username);
Not sure what happens when you have multiple users on the machine..

Viewing all articles
Browse latest Browse all 2206

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>