467,122 Members | 1,329 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,122 developers. It's quick & easy.

Windows service problem with network drive access

Hi all,

I have created a windows service that has a file watcher and does some operation after it reads that file. i developed it in my local machine and installed the service on server. i have changed the file path and everythng according to server drives.

we all in the office share some network drives in which ppl will keep pasting that file and the service on server has to pick it up. which its not doing. when i paste it in netwrok drive folder it picks up and works properly. but when someone else does that service doesn't work.when i check in the server the service has stopped. i had to start it manually.

i researched alot and found that windows service donot access network drives.i tried setting up installer acount to localservice, localsystem and also network service. nothng works. should i try user? i assumed it wont work since lot of them have to use this service. also all of them have read and write permissions to the network drive.

i dont understand what am i missing here. why does the service stop for other users. it'l be gr8 if someone can throw some light on this.

Thanks
Ayush
Jul 11 '08 #1
  • viewed: 2768
Share:
17 Replies
Hi all

let me make my question a little more clear. the windows service that i have created in my local system is installed on a server. and everyone accesss a network drive thats one of the folder in the server.

now my service works fine . but tte problem is it stops when some users use that network drive. like i put a file in that network drive it takes in, when user b puts a file it works as expected, but some user c puts a file in that network drive, it does not work and when i go in and check, the service actually stops and i have to restart the service. its wierd.

i have been reseraching for 3 days for this. this is really frustating. if anyone hasany clue pls let me know and i will research in that direction.

thanks,
Ayush
Jul 15 '08 #2
Plater
Expert 4TB
Are you doing any error checking in your service? Have it print out logs of what is going on at various places in the program?
Jul 15 '08 #3
Hi,

Thanks for you repaly. I debugged the service on my local machine. there are no bugs. i cannot debug it on the server. when i checked the event log on server it says service has terminated unexpectedly.

i dont understand why is it runing for some users and not for other users. its working for the creator that is me and admin. its not working for other users. service just stops as soon as another user access that network drive.

Ayush
Jul 16 '08 #4
and also i have try catch blocks every where and it writes the error to an error file in a folder. but the problem is service is not starting at all to go to any try catch block. i have added a try catch block in the start and stop events of the service. im trying to catch the error.

if any one has anymore suggestions please help me out.

Ayush
Jul 16 '08 #5
Plater
Expert 4TB
Is the service run as administrator?
Jul 16 '08 #6
No it does not run as administrator. should i have to impersonate.

Please let me know how should i make it run as an administrator.

Ayush
Jul 17 '08 #7
Plater
Expert 4TB
No it does not run as administrator. should i have to impersonate.

Please let me know how should i make it run as an administrator.

Ayush
Go into services.msc and right click on your service and choose properties. On the Log On tab, change to an administrator account.
that might help?
Jul 17 '08 #8
Thanks for replying so quickly.

right now in the logon I have NT AUTHORITY\NetworkService as account and its password. so I should change this to admin userID and password?
Jul 17 '08 #9
Plater
Expert 4TB
I'm not sure that the login credentials are even whats at fault here.
I have no idea why it can read the local share directory sometimes but not other times.
Jul 17 '08 #10
Ok. I noticed one thing the user for whom this service is not working does not have access to login to the server. he can access the network drive though.

service stops when he tries to put the file in network drive but when i restart it, it works. its not that the service does not work for him. its just that it stops. thats wierd behavior.
Jul 17 '08 #11
Plater
Expert 4TB
Does your service try to do anything like examining the username of the person who put the file in the directory?
Jul 17 '08 #12
No it doesn't check any userid and password.
Jul 17 '08 #13
Plater
Expert 4TB
Hmm very strange. And you're saying it never throws an access exception, like maybe when that user creates the file it gets marked with wierd privileges or something.
Could you just create an account for that user?
Jul 17 '08 #14
i have try,catch blocks everywhere even at the start and stop of the service. if an exception is caught it writes to an error file. but the problem is service just stops before going to any try catch block. the only thing that i can see in even log is that this service has stopped unexpectedly.

how can i create an account for this user?
Jul 17 '08 #15
Plater
Expert 4TB
how can i create an account for this user?
Well I don't know, but you said it happens when the user with no account on the server accesses the share directory. So I figure if you get them an account so they are like everyone else, you will not see the problem?
Jul 17 '08 #16
Oh ok got it. well its a development server and not everyone should have access to it. its companies rule i cant do much about it.
if nothing works out i am planning to install the service in that users machine and change the file paths accordingly. thats my last option.
Jul 17 '08 #17
Hi,

I have got it running somehow. this is the work around i used.

if somebody access the shared drive and the service stops then i made it to restart again with in some intervel. Right click on service name and go to recovery tab in that select first failure action as restart the service. and in the service, in start action, i check for files in the the folder. therefore the service which is stopped unexpectedly will restart and if a file exists it will do what ever it has to do.

my service actually moves the file from the folder and copies it to archives after it has used it.so usually the folder is empty. so above procedure worked for me. but i wish i can figure out a better way to do this.

thanks for all you help Plater
Jul 23 '08 #18

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Bonj | last post: by
1 post views Thread by mbah Sumani via .NET 247 | last post: by
10 posts views Thread by dermot | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.