Accessing network drive from Windows Service

  • Thread starter mbah Sumani via .NET 247
  • Start date
M

mbah Sumani via .NET 247

(Type your message here)
I Think it's the stupidness of Windows. Why the service can't access network drive but console apps or windows application can do it?
So my suggestion is make the program for accessing network drive in console apps, then call it with your windows service.. via windows API ..he..he that should work.

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
 
N

Nicholas Paldino [.NET/C# MVP]

The service can't access the network drive because by default, it runs
under the LocalService account, which does not have permissions to access
the network. Services do not get any special privledges by default. The
reason you can access the drive through a console or windows app is because
you have rights to it, and by extension, the program running has rights to
it as well.

If you create a console app and then call it from the service, it will
NOT work.

You need to change the account that the service runs under to the
NetworkService account. That has access to the network.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top