Service not able to access a mapped drive

Rohit picture Rohit · May 4, 2010 · Viewed 6.9k times · Source

I have read in many forums that mapped drives are not accessible from a service as no user is logged on.

Question 1) I tried making my service as a log on - as some account and i had my network drive mapped in that very account. The service still cannot access it. Why?

Question 2) From the same sevice, i invoke another process. Under what user account will the process run?

Thanks

Answer

Remy Lebeau picture Remy Lebeau · May 4, 2010

1) Use UNC paths instead, then you do not need access to mapped drive letters. As to why you cannot access them even when running in the same account, it is hard to say for sure without seeing your actual code.

2) it depends on how you are launching the process. If you use ShellExecute() or CreateProcess(), then it runs in the user account of the calling thread. If you use CreateProcessAsUser(), CreateProcessWithLogonW(), or CreateProcessWithTokenW(), then it runs in the user account that you pass in.