c# - 以另一个用户身份使用 process.start 运行 vbs,避免 UAC

标签 c# vbscript passwords process.start

我正在尝试使用 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.


编辑: 您所说的是用户模拟:

您可以查看其中一些文章

  1. WindowsIndentity Class
  2. http://www.codeproject.com/Articles/10090/A-small-C-Class-for-impersonating-a-User
  3. http://www.codeproject.com/Articles/4051/Windows-Impersonation-using-C
  4. Windows Impersonation from C#
  5. http://support.microsoft.com/default.aspx?scid=kb;en-us;Q306158
  6. http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.windowsforms/topic62740.aspx

关于c# - 以另一个用户身份使用 process.start 运行 vbs,避免 UAC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10276519/

相关文章:

c# - 如何重新启动 C# WinForm 应用程序?

VBA 在运行时添加到数组

html - 创建批处理/可视化基本脚本以将随机引用放入 html 文件中

scripting - FileSystemObject - 读取 Unicode 文件

unix - 使用 wget 从受密码保护的链接下载文件

带有哈希的 php 密码检查不起作用

c# - 调整大小和存储图像但锁定以确保它只完成一次

c# - 如何以 xamarin 形式隐藏 android(返回,主页)的底部栏?

mysql - 您如何在 MySQL 中安全地存储用户的密码和盐?

C# 如何使用 DataAnnotations StringLength 和 SubString 删除文本