I have a service that should copy some files over a network, the service is running under one of the local administrator accounts.

Logged in as that administrator I can manually copy the files from the network to a specific folder under Program Files, but the service exists with a PermissionDenied exception to WRITE the file. I'm also sure that the files are not being locked before the writing.

The error is as follows:

Access to the path ".../SomeAssembly.dll" is denied.

Why is the service giving me such an error and how can I correct it? (I also developed the service, so changes to the assembly could be on the table).


I also tried running it under System but it can't read the files on the network (dunno why) the LocalService and NetworkService accounts AFAIK don't have enough privileges to make changes to ProgramFiles... do they?

Update 2

The reason why I can't use System is because that account has no access to network resources by design, same happens for NETWORK SERVICE that has no access to local resources. The problem with the administrator account seems to be that Windows is blocking the file-copy operation when it's performed by the service.

Any ideas????


Well first I'd check to see if any of the files are marked as "Read-Only" as I've seen this attribute will sometimes supersede NTFS permissions. I've seen cases where you can copy over the file in the gui, after clicking yes to a "are you sure? " prompt, but any attempts to use a program to write data to it fail right away, no prompt given.

Also I'd make sure that the service, and and related services are actually running under the account you think they are. I've seen some cases where a service A will call service B to perform some task then hand the results back to Service A to finish off the task. And if only Service An is using the account with the proper permissions then the attempt will fail (as even though An is calling B it doesn't force it to run as the same user An is using so if B isn't itself configured to use the proper user it'll use the default one which may not have access to the particular spot you want)

Also if possible make sure what path it's using as a path like c:\program files\SomeAssembly.dll\somefile.txt or something like C:/users/don/app/SomeAssembly.dll could also give errors.


At the end what I did was have the application copy the files from the remote resource to a low-restriction folder (Application Data if I recall correctly) and then invoke the service, running under System, to copy them to Program Files.

The advantage for this approach is that it doesn't need administrative rights to copy the files over the network to the local drive (as long as you have the right read permissions on the network files of course) and then it also takes advantage on the low restrictions imposed to System to write to Program Files.


Depending on what the other computer is running, services generally run under the Network Services account or Local Systems account.

I'd try that first.

  • I think you are taking about to kill the service or something else? – avirk Aug 26 '11 at 17:18
  • You can always configure the account under which the service runs. Mine ain't running under neither of those, instead it's under an administrator account created by me, which I'm sure has sufficient privileges to perform the tasks. – PedroC88 Aug 26 '11 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.