以其他用户身份运行应用程序 [英] Running an application as different user

查看:71
本文介绍了以其他用户身份运行应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以其他用户身份运行项目,但是我看到的所有解决方案都是以其他用户身份启动流程.我想将用户名硬编码到项目中,以便每次运行程序时都以该用户身份运行.我之所以需要它,是为了使在我的网络上没有特权的用户能够启动和停止服务器上的服务.

I want to run my project as a different user but all the solutions I have seen are for initiation of a process as a different user. I want to hard code the username into the project so that every time the program is being ran it runs as that user. The reason I need this is so that users that don't have privileges on my network to be able to start and stop services on the server.

因此,我需要将用户名和密码安全地存储在程序中,以便每次运行时都以该用户身份运行.

So I need something like having the username and password securely stored in the program so that every time it runs it runs as that user.

正如我之前说过的,我以前发现的所有内容都是模拟用户,只是为了启动一些外部过程,但我需要从该用户开始.

As I previously said all I've found previously is impersonation of a user just to start some external process, but I need it to start with that user.

编辑

我找到了解决问题的方法,那就是PsExec.

I have found the solution to my problem and it's PsExec.

推荐答案

还有其他一些替代方法可以帮助实现这一目标,例如PsExex工具. https://technet.microsoft.com/en-us/sysinternals/psexec.aspx

There are also some other alternatives which can help in achieving this like PsExex Tool. https://technet.microsoft.com/en-us/sysinternals/psexec.aspx

您可以从Process类中提供所需的参数(如用户名,密码,要启动的过程),它将使用这些用户凭据成功启动它.

You can provide the required parameters (like username , password ,the process to start) from Process class and it will launch it successfully using those user credentials.

有关更多信息:-例如psexec \ workstation64 -c test.bat -u用户名-p密码

E.g. psexec \workstation64 -c test.bat -u USERNAME -p PASSWORD

对于我来说,它没有任何问题.

It works in my case without any issue.

这篇关于以其他用户身份运行应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆