Access mapped drive from a Windows Service

  • Thread starter Thread starter Anthony Boudouvas
  • Start date Start date
A

Anthony Boudouvas

Hi to all,

is there a way to access a mapped network drive from
a Windows Service application ?

I created a very simple one, using a timer that checks for a file existance
on G:\Emails
(a Novell server mapped drive)
I created the Service with "LocalSystem" for the ServiceProcess.Account
and it cannot find the G:\ drive.

I try to declare it to run under the Administrator account but when it tries
to install (installutil) it asks for the credentials and it then fails,
even if the UserName/Password stuff is correct...

Does anyone has a solution to this ?

Thanks a lot for any help


anthonyb
 
Since it's a mapped drive, that drive does not exists for the account you
used. I would suggest instead of using G:\, to use an UNC Path, for example
\\myserver\myshare\
--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan
 
Hey Jan,
many thanks for the quick reply!

I also tested that, in fact if i use the command
Console.WriteLine(File.Exists(@"\\med\vol1\emails\a.txt").ToString());
in a Console Application, it gives me true,

but if i give that in the Windoew Service, in form of
EventLog.WriteEntry(File.Exists(@"\\med\vol1\emails\a.txt").ToString()));

it gives me false...

Does another idea come to your mind ?

Thanks again!

anthonyb
 
Mapped drive is mapped for some specific user, while service is running in
another context and is not aware of this mapping.
There is a privilege called "Log on as a service". The user account you
specify for service should have this privilege. Use secpol.msc to grant it.
Also consider specifying URN path, like \\someserver\SomeShare\Email instead
of G:\Emails.
You might also experience problems accessing shares with
yourcomputer\LocalSystem principal...
 
Hey Max,

thanks for the reply.

Ok, i see the problem.
I state in ServiceProjectInstaller that i want to run under the "User"
property value.
I also use the secpol.msc to tell thet a user account (the same that i log
in to my system)
will have the "Log on as a service" priviledge.
Bu when i run the installutil and give it the credentials for that account,
i got back a "The account name is invalid or the password for this account
is invalid .."
message, even if they DO exist and they are correctly given to it...

A, as i told toy Jan (that already posted a reply to me),
the command
EventLog.WriteEntry(File.Exists(@"\\med\vol1\emails\a.txt").ToString()));

that i run from the Windows Service, gives me false...


Another thing to check ?

Thanks a lot !

anthonyb
 
Your user account that you are using for the service probibly does not
have permissions on the server...

S. Steefel, MCSE
Snr. Software Engineer
 
Back
Top