Network drive not available when the FTP script is scheduled



As all Windows applications, ScriptFTP supports the use of UNC paths and network drives. You can use the files and folders stored in them as if they were located in hard drive of the machine where ScriptFTP is running. For instance:

 

# Upload to the FTP server all the Excel files stored in the mapped network drive Z
PUTFILE("Z:\the_folder\*.xlsx")
 
# Upload to the FTP server all the Word documents stored in a network share called Reports
# under the computer named ACCOUNTING-PC-1
PUTFILE("\\ACCOUNTING-PC-1\Reports\*.docx")

A very common issue that sometimes happens with the use of network shares is that they will work when you click Run in the ScriptFTP window but will not if you schedule the script. When scheduled you may get an error as if the network drive does not exist at all, even if you are connected to the network. For example if the mapped drive is Z: and we try to set the current working directory to Z:\XML\Invoices:

LOCALCHDIR("Z:\XML\Invoices")
****** LOCALCHDIR Error #15000
****** Could not find a part of the path 'F:\XML\Invoices\'.

If this happens you should check the following:

– Check that the account running the scheduled script is actually the same account you used to map the network drive. Network drives are usually not system-wide. Every user has its own set of mapped network drives. You can check that opening the task scheduler and checking the task properties:

– Check that, if the task is set to run whether or not the user is logged in, the script creates the network share itself using the following command:

# Map the network drive from the script. Just in case
# the user is not logged in
EXEC("net use Y: \\server\share")

This is because mapped network drives are created when the user logs in and if the user is not logged in the mapped network drive will not be available. That command creates the mapping and you should use it before using the files on that drive.