Knowledge Base

Enter search queries below or use the tag links to the right to browse the knowledge base by category (Show All Tags).

DOSCMD and mapping a network drive

There are some cases where referencing a letter drive is preferable to using a UNC path. For example, if you are using the DOSCMD command to run certain shell commands then you might need to map a letter drive (some shell commands do not work with UNC paths).

To map a letter drive, use the EXEC script command to run the Windows 'net' command. For example, to mount a network drive, say drive G, issue a command such as:

EXEC "net use G: \\server\path"

Do this before attempting to access drive G.

If you need to submit a user name and password to connect to the network share, the command might look something like this:

EXEC "net use G: \\server\path mypassword /user:mydomain\myusername"

Here is a link an article from Microsoft's knowledge base that describes the net use command:

Warning: Mapped drives may not be available when Robo-FTP is launched as a Windows Service or by a Scheduled Task.

Microsoft recommends using a UNC path instead of a mapped drive to access network files from a service. See:

Therefore, if DOSCMD seems like a good solution to an automation challenge involving a network resource you should consider Microsoft's warnings and any potential workarounds before deciding to map a drive in a Robo-FTP service script.

See also:

Script failure, when running Robo-FTP as a service, when it attempts to access a network share.

Article last updated: 2022-01-06

Tags: Robo-FTP, DOSCMD, network, shares