开发者

Running Services.msc as a different User C#

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 whethe开发者_高级运维r 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?

Thanks


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

mmc.exe services.msc


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜