mardi 16 mars 2021

Batch file IF statement syntax

I am trying to update a batch file, but I am unfamiliar with the syntax. In the following code, the IF statement is not recognized.
First question, what is the correct syntax of the IF statement? I tried several combinations of arrangements of the quote characters, but have removed them for this example. Second question, what is the purpose of the "^" at the end of some of the lines? Third question, what is the purpose of the indent in the lines following the first line?

F:\Tools\WinSCP\WinSCP /command="option batch on" ^ "option confirm off" ^ "open WinSCP-ProfileName" ^ 
 "lcd F:\Data\TargetDirectory" ^
 "get ""*_SourceFileName.txt"" %TargetFileName%" ^
 IF %computername%==xxx GOTO LabelElse ^
 "echo do something here" ^
 :LabelElse ^
 "exit" /log=F:\Logs\LogFileName.log

Thanks!

Aucun commentaire:

Enregistrer un commentaire