title: How to change an FTP upload VBScript to SFTP
body: <p>I  want to change this to the SFTP server. How should I update this following script?</p>
  
  <pre><code>'FTP Upload
  'Upload a file/folder to an FTP server 
  
  Set oShell = CreateObject("Shell.Application")
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Dim objFSO
  Varnow = now
  vardate = Day(varnow) &amp; "-" &amp; Month(varnow) &amp; "-" &amp; Year(varnow) &amp; ".csv"
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  strFile = "D:/file.csv"
  strRename = "D:/file-" &amp; vardate
  If objFSO.FileExists(strFile) Then
      objFSO.MoveFile strFile, strRename
  End If
  
  'Path to file or folder to upload
  path = strRename
  
  FTPUpload(path)
  </code></pre>
  
  
  
  <pre><code>Sub FTPUpload(path)
  
      On Error Resume Next
  
      'Copy Options: 16 = Yes to All
      Const copyType = 16
  
      'FTP Wait Time in ms
      waitTime = 8000
  
      FTPUser = "ftuser"
      FTPPass = "psw"
      FTPHost = "hostname"
      FTPDir = "/Dir"
  
      strFTP = "ftp://" &amp; FTPUser &amp; ":" &amp; FTPPass &amp; "@" &amp; FTPHost &amp; FTPDir
      Set objFTP = oShell.NameSpace(strFTP)
  
      'Upload single file      
      If objFSO.FileExists(path) Then
          Set objFile = objFSO.getFile(path)
          strParent = objFile.ParentFolder
          Set objFolder = oShell.NameSpace(strParent)
  
          Set objItem = objFolder.ParseName(objFile.Name)
  
          objFTP.CopyHere objItem,copyType
      End If
  
      If Err.Number &lt;&gt; 0 Then
          Wscript.Echo "Error: " &amp; Err.Description
      End If
  
      'Wait for upload
      WScript.Sleep waitTime
      If objFSO.FileExists(strRename) Then
          objFSO.MoveFile strRename, strFile
      End If
  End Sub
  </code></pre>
  
  <p>So as you see I want to switch the FTP upload to SFTP upload (because the destination server have been changed to the SFTP protocol. What should be modified exactly in the this function <code>Sub FTPUpload(path)</code> to do so?
  Have you any tips to do so? </p>