Reputation: 11304
My winform executable calling AppData of the user directory.
Now When I am trying run my app with User1
using below code, my app looking "Default" user directory instead of User1
directory. What could be the reason?
Access to path 'C:\Users\Default\AppData\Local\DataFolder is denied
string CommandDirectory = @"C:\Program Files (x86)\Apps\";
var process = new Process
{
StartInfo =
{
FileName = string.Format("{1}{0}Utility.exe", Path.DirectorySeparatorChar, CommandDirectory),
WorkingDirectory = string.Format("{0}", CommandDirectory),
RedirectStandardError = true,
RedirectStandardOutput = true,
UseShellExecute = false,
UserName = "User1",
Password = "Password1".ToSecureString(),
Domain = "Machine-Name",
},
};
process.Start();
Note - If I use verb
and remove UserName
, Password
, Domain
, then works find and looks correctly for Admin user folder,
UseShellExecute = false,
//UserName = "User1",
//Password = "Password1".ToSecureString(),
//Domain = "Machine-Name",
Verb = "runas"
Upvotes: 1
Views: 63