Skip to content

Network Folder Access in Windows Service

wajid khan

Asked Jun 15, 2006, 12:17 AM EDT1 answer
Share
LinkedInX
Hi

I am writing a windows service which is supposed to write some files on a network shared folder.

Through my research on net I came to know that I need to run this service under the same NetworkService account which has permission on Network shared folder. I set the UserName and Password in Project Installer File.

I run the service using UNC convention to access the network shared folder and got Path Not Found error.

Than I manually mapped the shared folder using the same domain account which I set to run the service and tried to use the Shared Drive path to access the destination folder and got the same Path Not Found error.

Now reading different posts on net about similar problem I came to know I can map the shared folder programatically in my windows service using WMI. I want to know someone succeeded to access the network resource in Windows service or not? If yes than how?

I am stuck. Please Help.

Thanks is advance

Regards

Wajid

>> Apologies if you feel this is not the correct forum for this question. Unable to find relative forum on this site.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0

    Posting solution hope it will be helpfull for others.

    1) Service account will remain same to LocalSystem.

    2) You need to map the shared folder(mapped drive) inside your web service using
    Win32 API mpr.dll

    Method in API --> WNetAddConnection2A

    this method needs parameters like Domain UserName and Password.

    Later use that mapped drive letter to read, write or whatever you are allowed to do by this Domain User.

    Cheers
    0