I have a Win Forms application in C# which runs on employees PC's. Within the application, i call another executable using Process.Start, but i pass a username and password of a user which has administrator privileges on the domain, because employees don't have permissions to run the executable.
The executable is in a folder on C:
The exe starts successfully on Windows XP machines, but fails with "Access Denied" error on Windows 7. i didn't find a solution. Any idea?
try
{
var pass = new SecureString();
pass.AppendChar('b');
pass.AppendChar('l');
pass.AppendChar('a');
pass.AppendChar('b');
pass.AppendChar('l');
pass.AppendChar('a');
var pro = new ProcessStartInfo
{
FileName = AppDomain.CurrentDomain.BaseDirectory + "myExe.exe",
UserName = "username",
Password = pass,
Domain = "domain",
UseShellExecute = false,
RedirectStandardError = true,
RedirectStandardOutput = true,
RedirectStandardInput = true
};
Process.Start(pro);
}
catch (Exception x)
{
MessageBox.Show("Failed to call updater.\n" + Help.ErrorMsg(x)); Application.Exit();
}
Hei,
Win Forms application must run with admin privileges in order to start another process with higher privileges.
Your problem is not related to c#. It's a UAC problem.
Given the fact that you are giving them and exe to run something with elevated rights, I assume that you took in consideration that an user can use a decompiler to see the credentials.
Also, if you wanna do it right, I suggest using an MDM solution like Microsoft SCCM ( https://www.microsoft.com/en-us/cloud-platform/system-center-configuration-manager ). With something like this you can do:
You can control end users PCs and you don't have to give them elevated rights.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.