ssa
11 years agoOccasional Contributor
Unable to execute a batch file from TC using JS.
I am trying to execute a .bat file that opens a FTP connection to a server and put a file on specified location. If i manually issue this command in the command prompt C:\>ftp -i -s...
- 11 years ago
Does your ftpConnection.bat file has the lcd command to specify the local folder that contains the files for upload? Like this:file is not sent to the destination
lcd C:\MyFolder
mput *.txt
Without lcd, ftp looks for files in the current working folder, which in this case is your TestComplete project folder.
To leave the command prompt window open after running the command, use .Run("cmd /k command"):the command prompt exits immediately so unable to see the message.
Sys.OleObject("WScript.Shell").Run("cmd /k ftp -i -s:C:\\ftpConnection.bat", 1, false);
Or if you want to pause the script until the FTP transfer completes, use .Run(command, 1, true):
Sys.OleObject("WScript.Shell").Run("ftp -i -s:C:\\ftpConnection.bat", 1, true);