以不同用户身份运行 Services.msc C#

发布于 2024-08-26 20:22:25 字数 300 浏览 7 评论 0原文

我需要创建一个简单的 Windows 窗体应用程序,允许管理员用户管理远程服务器上的服务。我们不想向管理员提供服务器的用户名和密码,因此这些内容将被加密并存储在数据库中。

我的问题是,在模拟数据库中存储的用户之一时是否可以生成 Services.msc 窗口?

我已经查看了 ProcessStartInfo 类,但由于 Services.msc 不是可执行文件,因此它似乎不喜欢执行该类。关于执行实际模拟和加载 Services.msc 的简单方法(例如单击按钮)有什么想法吗?

I have a requirement to create a simple windows forms application that allows an admin user to manage the Services on remote servers. We don't want to give the admins the usernames and passwords to the servers so these will be encrypted and stored in a database.

My question is whether or not it is possible to spawn a Services.msc window when impersonating one of the users stored within the database?

I have looked at the ProcessStartInfo class but because Services.msc is not an executable it does not seem to like executing this. Any ideas on a simple way of doing the actual impersonation and loading of Services.msc - say off a button click?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心安伴我暖 2024-09-02 20:22:25

文件扩展名 msc 与 mmc.exe 关联。您需要开始以下操作:

mmc.exe services.msc

File extension msc is associated with mmc.exe. You'll want to start the following:

mmc.exe services.msc
滴情不沾 2024-09-02 20:22:25

斯彭德速度更快,所以他获得了积分。这就是我所做的,以防万一它对某人有用。

SecureString ss = new SecureString();
ss.AppendChar('X');
// other calls to AppendChar
ProcessStartInfo psi = new ProcessStartInfo() {
    UserName = "XXX", Password = ss, Domain = "XXX",
      UseShellExecute = false,
      FileName = "mmc", Arguments = "services.msc"
  };
Process.Start(psi);

Spender was faster, so he gets the credits. Here is what I did, just in case it is useful to someone.

SecureString ss = new SecureString();
ss.AppendChar('X');
// other calls to AppendChar
ProcessStartInfo psi = new ProcessStartInfo() {
    UserName = "XXX", Password = ss, Domain = "XXX",
      UseShellExecute = false,
      FileName = "mmc", Arguments = "services.msc"
  };
Process.Start(psi);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文