sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
Anthony Boudouvas's Avatar

Access mapped drive from a Windows Service


Question posted by: Anthony Boudouvas (Guest) on November 15th, 2005 05:41 PM
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


5 Answers Posted
Jan Tielens's Avatar
Guest - n/a Posts
#2: 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]


Anthony Boudouvas's Avatar
Anthony Boudouvas November 15th, 2005 05:41 PM
Guest - n/a Posts
#3: 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\emails\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]



Max's Avatar
Guest - n/a Posts
#4: 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]


Anthony Boudouvas's Avatar
Anthony Boudouvas November 15th, 2005 05:41 PM
Guest - n/a Posts
#5: 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\emails\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]


Sean S.'s Avatar
Guest - n/a Posts
#6: 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!
 
Not the answer you were looking for? Post your question . . .
196,842 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 196,842 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors