Windows Service
-
Hi all, I have an urgent question. I am writing an windows service to retrieve files from a network drive mapped as Y: I get the following error... Could not find a part of the path "Y:\verify". When I run an Application it works fine, so I tried to shell the exe from my service, but still get the error! I have read and tried several things but to no success :( Can anyone please assist me?:sigh:
-
Hi all, I have an urgent question. I am writing an windows service to retrieve files from a network drive mapped as Y: I get the following error... Could not find a part of the path "Y:\verify". When I run an Application it works fine, so I tried to shell the exe from my service, but still get the error! I have read and tried several things but to no success :( Can anyone please assist me?:sigh:
Have you tried the UNC e.g. instead of : "Y:\somefile.txt" Try (depending on the path): "\\FredsComputer\C$\somefile.txt"
You always pass failure on the way to success.
-
Have you tried the UNC e.g. instead of : "Y:\somefile.txt" Try (depending on the path): "\\FredsComputer\C$\somefile.txt"
You always pass failure on the way to success.
Yes I have tried that, but the share needs authentication. So I get access denied error :(
-
Yes I have tried that, but the share needs authentication. So I get access denied error :(
Sounds like a permissions/user issue. I am not a networks expert and I guess someone else on this forum may be able to help. Good luck...
You always pass failure on the way to success.
-
Hi all, I have an urgent question. I am writing an windows service to retrieve files from a network drive mapped as Y: I get the following error... Could not find a part of the path "Y:\verify". When I run an Application it works fine, so I tried to shell the exe from my service, but still get the error! I have read and tried several things but to no success :( Can anyone please assist me?:sigh:
A Windows Service runs, by default, as the Local System account, which has no rights to any network resources. The service does NOT run under the user context. It runs as if a seperate user logged into the machine (actually it DOES login to Windows) with no network permissions. To the service, there is no Y: drive. The only drives that exist are the local floppy, hard drive, and any CD/DVD drives. If you want the server to have access to the network, you have to change the account it's running under to one that has network permissions. Click Start/Run and type
services.msc
. Find your service in the list and double-click it. In the dialog that shows up, click theLogOn
tab to change the account.A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
A Windows Service runs, by default, as the Local System account, which has no rights to any network resources. The service does NOT run under the user context. It runs as if a seperate user logged into the machine (actually it DOES login to Windows) with no network permissions. To the service, there is no Y: drive. The only drives that exist are the local floppy, hard drive, and any CD/DVD drives. If you want the server to have access to the network, you have to change the account it's running under to one that has network permissions. Click Start/Run and type
services.msc
. Find your service in the list and double-click it. In the dialog that shows up, click theLogOn
tab to change the account.A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007Thanx for the reply. I have tried that approach but maybe i'm doing something wrong? I log in with a domain account, so in the service properties I specify my logon details. But then I run the service it can still not access my mapped drive :(( Got any idea why it would do this?
-
Hi all, I have an urgent question. I am writing an windows service to retrieve files from a network drive mapped as Y: I get the following error... Could not find a part of the path "Y:\verify". When I run an Application it works fine, so I tried to shell the exe from my service, but still get the error! I have read and tried several things but to no success :( Can anyone please assist me?:sigh:
Hi all, thanx for the replies. I found a way to let a windows service access a mapped drive. I knew that only the user creating the network drive can see it, so the service would have to create a mapped drive in itself.... I found this great article, just compiled the class into a dll and used it in my service. Works great, so if any one has the same problem..... http://www.codeproject.com/csharp/mapnetdrive.asp?df=100&forumid=39622&select=2248704&msg=2248704[^]
-
Thanx for the reply. I have tried that approach but maybe i'm doing something wrong? I log in with a domain account, so in the service properties I specify my logon details. But then I run the service it can still not access my mapped drive :(( Got any idea why it would do this?
DO NOT CROSSPOST in multiple forums. It makes collaboration on an answer impossible. Did you map the drive by hand yourself at any time or did a login script do it for you?? If it wasn't through a login script, then the service will not see the mapped drive because it hasn't mapped it itself. Using mapped drives is a bit old-fashioned anyway. If you used UNC paths, you haven't have to worry about the mapping at all. The service still needs to run under a network account though.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
Thanx for the reply. I have tried that approach but maybe i'm doing something wrong? I log in with a domain account, so in the service properties I specify my logon details. But then I run the service it can still not access my mapped drive :(( Got any idea why it would do this?
MaYo69 wrote:
Got any idea why it would do this?
Because the service logs in under its own security context. It's not aware that you logged in under the same account. It's completely in its own litte world. Nothing you do under your account will affect what the service sees.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007