7

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?

bcpettifer
  • 453
  • 8
  • 17
E-Max
  • 401
  • 5
  • 14
  • Have you tried watching it in [Process Monitor](http://technet.microsoft.com/en-us/sysinternals/bb896645)? That might show you exactly what it can't access. But it sounds like the user switching might be the problem though. – Rup May 10 '11 at 10:52
  • I tried ProcMon, but it show nothing useful for me. There is no errors at the log. And what about user-switching problem? – E-Max May 10 '11 at 11:10

1 Answers1

0

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");
Martin Brown
  • 24,692
  • 14
  • 77
  • 122
  • I have the same problem... already tried to call a .bat file, use WMI, impersonation, but no success. Any update @E-Max? – Fernando Jul 15 '13 at 18:34