title: Using VBA to run WinSCP script
body: <p>I am able to download files from SFTP in <code>CMD</code> window, by using following code:</p>
  
  <pre class="lang-none prettyprint-override"><code>WinSCP.com
  # Connect to the host and login using password
  open user:pw@address
  # get all the files in the remote directory and download them to a specific local directory
  lcd C:\Users\xx\Desktop
  get *.xlsx
  # Close and terminate the session
  exit
  </code></pre>
  
  <p>I searched online and found out that I can put these codes in a <code>bat</code> file and use </p>
  
  <pre><code>Call Shell("cmd.exe /c C:\Users\xx\Desktop\WinSCPGet.bat", 1)
  </code></pre>
  
  <p>However, only the first line of the bat file <code>WinSCP.com</code> is being executed. It will pop up the <code>cmd</code> window, showing this, without doing anything else.
  <a href="https://i.stack.imgur.com/AKQKH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AKQKH.png" alt="enter image description here"></a></p>
  
  <p>How to execute all the lines at one time?</p>
  
  <p>Thanks</p>