Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 Windows 2008 上有三个帐户:Admin、User1、User2、User3。我想在这些 User1、User2、User3 帐户上使用 c# 从管理员帐户运行 GUI 程序。问题在于,在使用Process.StartUser1 或任何其他用户凭据时,GUI 应用程序会在管理员用户桌面上启动。我想在 User1 桌面上运行程序。我想像我们手动一样模拟行为:切换用户,使用 User1 登录,运行 GUI 程序。有可能这样做吗?
Process.Start
如果这就是您的意思,您应该能够使用不同的用户凭据运行该程序。
var processInfo = new ProcessStartInfo { FileName = "app.exe", UserName = "Username", Domain = "yourdomain or leave blank", Password = "password", UseShellExecute = false, }; Process.Start(processInfo);