从Windows Service执行Process.Start时访问被拒绝 [英] Access Denied when executing Process.Start from Windows Service
问题描述
我正在尝试以另一个用户的身份从服务运行一个进程.
I'm trying to run a process from the service as another user.
Process.Start(applicationPath, params, account, SecureStringPassword, "");
服务正在本地系统"帐户下运行.
A service is running under the "Local System" account.
account
参数是一个字符串,例如"WORKSTATION6 \ Tester".该用户是Administrators组的成员.
The account
parameter is a string like "WORKSTATION6\Tester". This user is a member of the Administrators group.
应用程序路径"是指程序文件,因此每个用户都可以读取它.
"Application Path" refers to Program Files, so every user can read from it.
但是,每次尝试启动该过程时,都会出现访问被拒绝"异常.您能提供什么建议?
But I have an "Access Denied" Exception every time I try to start the process. What can you advice?
推荐答案
在SecureString页面上有一个有关如何使用Process.Start的示例. http://msdn.microsoft.com/en-us/library/system.security.securestring(v = VS.90).aspx#Y682
There is an example of how to use Process.Start on the SecureString page. http://msdn.microsoft.com/en-us/library/system.security.securestring(v=VS.90).aspx#Y682
我认为您需要做的是将用户帐户的域放在最后一个参数中,如下所示:
I think what you need to do is put the domain of your user account in the last parameter like this:
Process.Start(applicationPath, params, "Tester", SecureStringPassword, "WORKSTATION6");
这篇关于从Windows Service执行Process.Start时访问被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!