我正在尝试使用 process.start() 作为具有管理员权限的另一个用户运行 vb 脚本,但我总是弹出 UAC 弹出窗口,其中包含要填写的用户名和密码。我做错了什么?
var scriptProc = new Process
{
StartInfo =
{
FileName = @"cscript,
WorkingDirectory = @"\\AShare\AFolder",
Arguments = "\"" + "Install.vbs" + "\"",
UseShellExecute = false,
WindowStyle = ProcessWindowStyle.Hidden,
Domain = domain,
UserName = username, //Admin username
Password = MakeSecureString(secureString),
}
};
scriptProc.Start();
我希望 UAC 弹出时带有"is"和“否”选项,而不是带有用户名和密码来填写选项。
尝试查看:How to call a VBScript file in a C# application?但这没有帮助。
最佳答案
您没有做错任何事,在 Windows 7 中,即使管理员帐户也以标准用户权限运行。看看这个TechNet article by Mark Russinovich
摘自上述文章。
When UAC is enabled, all user accounts—including administrative accounts—run with standard user rights. This means that application developers must consider the fact that their software won't have administrative rights by default. This should remind them to design their application to work with standard user rights. If the application or parts of its functionality require administrative rights, it can leverage the elevation mechanism to enable the user to unlock that functionality.
编辑: 您所说的是用户模拟:
您可以查看其中一些文章
- WindowsIndentity Class
- http://www.codeproject.com/Articles/10090/A-small-C-Class-for-impersonating-a-User
- http://www.codeproject.com/Articles/4051/Windows-Impersonation-using-C
- Windows Impersonation from C#
- http://support.microsoft.com/default.aspx?scid=kb;en-us;Q306158
- http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.windowsforms/topic62740.aspx
关于c# - 以另一个用户身份使用 process.start 运行 vbs,避免 UAC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10276519/