简体   繁体   中英

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.

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM