DOSCMD Execute an internal MS-DOS command |
Top Previous Next |
This script command opens a DOS command console window and executes the command specified by the [ cmd ] argument. Unlike the EXEC script command, you can use DOSCMD to run MS-DOS internal commands. Robo-FTP script execution is suspended while the command is console is running. The command console window closes automatically when the command specified by the [ cmd ] argument is finished running.
Important The Windows command console does not support UNC paths as the current local working directory. If DOSCMD is executed while the Robo-FTP working directory is a UNC path the console will default to the Windows installation directory. Use the WORKINGDIR command to choose a different working folder before executing DOSCMD. Scripts that must call DOSCMD with a network folder should map a drive (see Working with Network Drives) with EXEC and net use.
The /timeout option allows you to specify the maximum amount of time to wait for the command console window to close. This option is useful for protecting your command script from unreliable external commands. If you do not specify a timeout and the command hangs waiting for user input (ie: Abort, Retry, Fail?) then Robo-FTP will also wait indefinitely. If the launched DOS command console window does not complete execution prior to the end of the timeout period then Robo-FTP will close the DOS command console and continue processing its script with the next line. A timeout does not necessarily close external programs launched by the DOS command console.
Consider the following example that runs a batch file:
DOSCMD "DoSomething.bat"
Consider the following example that lists the contents of the current folder to a file:
DOSCMD "dir *.* > tempfile"
Consider the following example where a new folder is created and the contents of the current folder is copied there:
DOSCMD "mkdir \newfolder" DOSCMD "copy *.* \newfolder"
Consider the following example where single quote characters are used to delimit the string constant passed to the [ cmd ] argument so that the double-quote characters may be passed to the command console:
DOSCMD 'mkdir "new folder"'
Upon return, any exit code from the process launched with DOSCMD is saved in the %lasterror script variable and can be tested with any of the IFERROR commands. For example:
DOSCMD "fc file1.txt file2.txt" ;; "fc" returns 2 if it cannot compare the specified files IFERROR= 2 GOTO fc_error
Use the EXEC command to launch an external Windows application.
Related command(s): EXEC, CALL, CHAIN See also: Script File Result Codes, Working with Network Drives |