Passing login information to remote windows file share

I have looked all over the net for information on how to do this and am still lost. I want to copy files from a remote server that has file sharing enabled, however the login information does not match the local domain. So when I try a File.Copy on the remote file I get a error unless I first launch iexplore to the URL of the site (\\10.100.1.1 for instance) and then it will allow the user to manually authenticate and after that it works. Is there any way to automate this and pass the login info

Answer this question

Passing login information to remote windows file share

  • FA65

    Anyone Or can someone suggest another forum I could ask at The impersonate stuff won't work in this example as the remote system is on a different domain. It's as simple as logging in via the windows prompt though, there has to be a way to automate this...
  • FrankChen

    Anyone Still really hoping for a reply, I can't believe windows doesn't have a way to do this via a API..

  • NEOjas

    Since no one ever really gave me a answer, I'll answer it myself. The above method was the solution to getting logged into the remote server on a different domain. The problem with my call to mapnetworkdrive() was the remote path has to include a share name, not just the ip address, so \\10.103.71.1\root would be a example rather than \\10.103.71.1

    Hope this helps someone else also...


  • markand

    I'm sorry, that's just not a option in this scenario, we do not have local access to those systems, thus one of the reasons I need to do this is TO upload files to the remote systems. I found the MapNetworkDrive function in the WSH scripting object, but I can't get it to work. I implement as:

    NetPathName = "\\\\" + IPListBox.Text;

    test.MapNetworkDrive("X:",NetPathName, ref UpDateObject, ref UserNameObject, ref PassWordObject);

    With iplistbox.text being a properly formatted ip address such as 10.103.71.1

    However all I ever get when this runs is:

    The network path was not found. (Exception from HRESULT: 0x80070035)

    When I test this path with Iexplore it works fine... What am I doing wrong! !


  • Nathan Tracy

    Create a seperate application which copies file from the remote Share, Now use Process Class' Start() method and pass username, password of specific domain which has right on that share to start the Copying application from your application:

    Here is what MSDN says:

    "Starts a process resource by specifying the name of an application, a user name, a password and a domain and associates the resource with a new Process component."

    Please see MSDN online for more details. I'm lazy to post the link right now coz I'm workign with offline MSDN right now.

    I hope this will solve your porblem.

    Best Regards,



  • Passing login information to remote windows file share