How can I call a batch file within another batch file?

Westfall_T

trying to call a batch file within another batch file the script completes the synchronization of the remote folders but then fails to call the other batch file.

@echo off

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\Test\TestLog.log" /ini=nul ^
/command ^
"open sftp://test/ -hostkey=""ssh-dss 2048 xxxxxxxxxxxxxxxxxxxxxxxxx=""" ^
"synchronize remote \\Please\Send\Some\Help /Dir/Test" ^
"exit"

set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
echo Success
) else (
echo Error
)

exit /b %WINSCP_RESULT%

CALL movefile

pause
IT Thug Ninja

Simply move the call command to be above the exit command or else it will exit before calling.


What to Change

This. . .

exit /b %WINSCP_RESULT%
CALL movefile
pause

Becomes this. . .

CALL movefile
pause
exit /b %WINSCP_RESULT%

Script

@echo off

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\Test\TestLog.log" /ini=nul ^
/command ^
"open sftp://test/ -hostkey=""ssh-dss 2048 xxxxxxxxxxxxxxxxxxxxxxxxx=""" ^
"synchronize remote \\Please\Send\Some\Help /Dir/Test" ^
"exit"

set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
echo Success
) else (
echo Error
)

CALL movefile
pause
exit /b %WINSCP_RESULT%

Note: You will also want to ensure the batch script file being called actually exists so confirm that is the accurate location from the executing batch script command that calls movefile.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Looping a batch file that calls another batch file

분류에서Dev

How can i resolve the path laocation in batch file

분류에서Dev

How can I run a batch file with a loop as a scheduled task?

분류에서Dev

How can I extract text before a character or string in a batch file?

분류에서Dev

How to make another batch file with variables using batch?

분류에서Dev

Batch file to move a folder into another

분류에서Dev

How I can I start a powershell command line from a batch file and enforce it to stay open?

분류에서Dev

I want to write a batch file that internally calls python script and I want python script to return some value to the batch file. how can I do that?

분류에서Dev

How can I pass command line arguments to a program in a Windows batch file?

분류에서Dev

How to create a batch file for this issue?

분류에서Dev

Opening a Batch file from another (Including Java)

분류에서Dev

How do I split directory addresses recursively in a batch file?

분류에서Dev

How do I convert this code so that it works in a Batch file?

분류에서Dev

How can I copy a text file into another?

분류에서Dev

How to run batch file command with elevated permissions?

분류에서Dev

How to sign a Windows batch (.bat) file?

분류에서Dev

How to go to label in called batch file

분류에서Dev

How to use "<<" in batch file or command prompt?

분류에서Dev

How to continue a batch file pause in PowerShell

분류에서Dev

How to check if a batch file has ANY parameters?

분류에서Dev

Batch get file contents

분류에서Dev

DOS Batch File & FOR statements

분류에서Dev

Batch file - file name extract

분류에서Dev

Spring Batch reader file by file

분류에서Dev

How can I check in Apex if a batch is scheduled?

분류에서Dev

Call MySQL stored procedure with parameter from batch file

분류에서Dev

Can I make a batch file that sets up a https proxy for IE without showing command line or window?

분류에서Dev

Batch file FOR loop to copy folders only if they exist in another folder

분류에서Dev

batch within batch call directories and jumping between labels

Related 관련 기사

  1. 1

    Looping a batch file that calls another batch file

  2. 2

    How can i resolve the path laocation in batch file

  3. 3

    How can I run a batch file with a loop as a scheduled task?

  4. 4

    How can I extract text before a character or string in a batch file?

  5. 5

    How to make another batch file with variables using batch?

  6. 6

    Batch file to move a folder into another

  7. 7

    How I can I start a powershell command line from a batch file and enforce it to stay open?

  8. 8

    I want to write a batch file that internally calls python script and I want python script to return some value to the batch file. how can I do that?

  9. 9

    How can I pass command line arguments to a program in a Windows batch file?

  10. 10

    How to create a batch file for this issue?

  11. 11

    Opening a Batch file from another (Including Java)

  12. 12

    How do I split directory addresses recursively in a batch file?

  13. 13

    How do I convert this code so that it works in a Batch file?

  14. 14

    How can I copy a text file into another?

  15. 15

    How to run batch file command with elevated permissions?

  16. 16

    How to sign a Windows batch (.bat) file?

  17. 17

    How to go to label in called batch file

  18. 18

    How to use "<<" in batch file or command prompt?

  19. 19

    How to continue a batch file pause in PowerShell

  20. 20

    How to check if a batch file has ANY parameters?

  21. 21

    Batch get file contents

  22. 22

    DOS Batch File & FOR statements

  23. 23

    Batch file - file name extract

  24. 24

    Spring Batch reader file by file

  25. 25

    How can I check in Apex if a batch is scheduled?

  26. 26

    Call MySQL stored procedure with parameter from batch file

  27. 27

    Can I make a batch file that sets up a https proxy for IE without showing command line or window?

  28. 28

    Batch file FOR loop to copy folders only if they exist in another folder

  29. 29

    batch within batch call directories and jumping between labels

뜨겁다태그

보관