I created the following C # console application:
var userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
var path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
var path2 = Environment.ExpandEnvironmentVariables("%userprofile%");
File.AppendAllText(@"D:\logs\info.txt", userName + " -- " + path + " -- " + path2);
When I create a scheduled task using the Windows Task Scheduler and set a user account to run the task in my account ( ht-laptop\huseyin), I get the following output in the info.txt file :
ht-laptop\huseyin -- C:\Users\Default\Documents -- C:\Users\Default
This seems random, although I saw cases where the printed text was as follows:
ht-laptop\huseyin
Any idea why this is happening?
source
share