Connecting Tech Pros Worldwide Help | Site Map

Access mapped drive from a Windows Service

  #1  
Old November 15th, 2005, 05:41 PM
Anthony Boudouvas
Guest
 
Posts: n/a
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


  #2  
Old November 15th, 2005, 05:41 PM
Jan Tielens
Guest
 
Posts: n/a

re: Access mapped drive from a Windows Service


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


"Anthony Boudouvas" <anthonyb@mediatrel.com> wrote in message
news:uyyUMFJxDHA.1704@TK2MSFTNGP10.phx.gbl...[color=blue]
> 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[/color]
existance[color=blue]
> 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[/color]
tries[color=blue]
> 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
>
>[/color]


  #3  
Old November 15th, 2005, 05:41 PM
Anthony Boudouvas
Guest
 
Posts: n/a

re: Access mapped drive from a Windows Service


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\email s\a.txt").ToString()));

it gives me false...

Does another idea come to your mind ?

Thanks again!

anthonyb





"Jan Tielens" <jan@no.spam.please.leadit.be> wrote in message
news:%23ZOFIQJxDHA.1996@TK2MSFTNGP12.phx.gbl...[color=blue]
> 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[/color]
example[color=blue]
> \\myserver\myshare\
> --
> Greetz
>
> Jan Tielens
> ________________________________
> Read my weblog: http://weblogs.asp.net/jan
>[/color]



  #4  
Old November 15th, 2005, 05:41 PM
Max
Guest
 
Posts: n/a

re: Access mapped drive from a Windows Service


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...

"Anthony Boudouvas" <anthonyb@mediatrel.com> wrote in message
news:uyyUMFJxDHA.1704@TK2MSFTNGP10.phx.gbl...[color=blue]
> 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[/color]
existance[color=blue]
> 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[/color]
tries[color=blue]
> 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
>
>[/color]


  #5  
Old November 15th, 2005, 05:41 PM
Anthony Boudouvas
Guest
 
Posts: n/a

re: Access mapped drive from a Windows Service


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\email s\a.txt").ToString()));

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


Another thing to check ?

Thanks a lot !

anthonyb

"Max" <Please@reply.to.news.group> wrote in message
news:eNmOBdJxDHA.2136@TK2MSFTNGP10.phx.gbl...[color=blue]
> 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[/color]
it.[color=blue]
> Also consider specifying URN path, like \\someserver\SomeShare\Email[/color]
instead[color=blue]
> of G:\Emails.
> You might also experience problems accessing shares with
> yourcomputer\LocalSystem principal...
>[/color]


  #6  
Old November 16th, 2005, 03:47 AM
Sean S.
Guest
 
Posts: n/a

re: Access mapped drive from a Windows Service


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

S. Steefel, MCSE
Snr. Software Engineer


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Service accessing mapped drive Bonj answers 3 November 16th, 2005 04:17 PM
Why can't access a file under network drive from Windows Service? Daniel Xiao answers 3 November 16th, 2005 08:03 AM
Why can't I access a file in Network driver from Windows Service? Daniel Xiao answers 1 November 16th, 2005 07:58 AM
Accessing Mapped Network Drive from Service Niloday answers 5 November 15th, 2005 06:59 PM