Search code examples
windowsnetwork-programminglocationwebdav

How to mount WebDAV share programmatically on Windows 7/Vista without assigning drive letter?


I need to mount WebDAV share programmatically on Windows 7/Vista without assigning drive letter. I know

net use

and

WScript.CreateObject('WScript.Network').MapNetworkDrive('E:', 'http://server/');

can mount WebDAV but they require drive letter. Any chance to mount WebDAV without assigning drive letter? For example Add Network Location Wizard can do this.


Solution

  • Use this to provide the credentials:

    net use \\www.foobar.baz\folder /USER:Foo /PASS:Bar
    

    Then, you can use the WebDAV drive by its UNC name (myCoolCommand.exe \\www.foobar.baz\folder)