Question

I have used SUBST command to create mapped drive to a certain folder. In a console application I can access the directory, while I cant access the same directory in a windows service application. In other words the following line returns false

Directory.Exists(@"x:\directory")

where x: is defined using SUBST as follow:

SUBST x: c:\xdrive

How can I access the subst-mapped directories in a windows service application?

Was it helpful?

Solution

Subst lives in your registry hive. The windows service must be running as you to access this. Change the crendentials of the service.

If this is not possible then you could programmatically create a link to the location. Such as by calling System.Process to run a cmd.exe /c subst command.

OTHER TIPS

The problem is that a virtual drive made using subset command is only visible to the user who made it. The service is running using another user privileges thus it will not be visible to service application.

If your service runs as Local System follow the instructions here:

http://blogs.msdn.com/b/adioltean/archive/2004/11/29/271987.aspx

That will get you a command prompt running as local service to take your subst command

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top