2

I have an application that opens a file, the path of which is set to what looks like a UNC path, but with the double slash and hostname removed i.e. instead of

\\HOSTNAME\SHARED\FILE

it has

\SHARED\FILE

This refers to the share SHARED on the local machine.

This all worked fine, until I switched the application to run as a Windows service. Now the application cannot open the file.

The service is running as a domain account which has full control of the share.

I would like to understand the meaning of this path format, why a Windows service can't access a file referred to with it but a console application can, and how to make this work without changing the path (if possible).

1

It's not an UNC path anymore. It's a regular local path that starts at the root (\) of the same drive as the current working directory of the process.

That is, if the cwd is c:\windows, the path \users\anthony would refer to c:\users\anthony.

  • 1
    OK, Windows services run in %WinDir%\System32 so \SHARED\FILE is referring to C:\SHARED\FILE but SHARED is actually on the `D:` drive. Thank you. – Anthony Apr 22 '15 at 5:23

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.