How to convert this bat into vbs format?

This is using a batch format for some sftp operations to the remote server. Please see the command as follows:

    scp2 -u PRODFTP@10.182.188.88:.\In\*.inf  D:\ftp_in

Due to the company policy , not batch file is allowed. Only vbs or ps1 file formats are allowed. BTW, how to convert the above operation into vbs format?

Thanks,
MezzutOzilAsked:
Who is Participating?
 
Bill PrewCommented:
If you don't want to capture the output from the SCP2 command then you can use the RUN command for that.  

If you want the VBS to wait for the SCP2 program to finish, and then report if an error occurred you can do:

Set oShell = WScript.CreateObject("WScript.Shell")
iReturn = oShell.Run("scp2 -u PRODFTP@10.182.188.88:.\In\*.inf  D:\ftp_in", 0, True)
If iReturn <> 0 then
   Wscript.Echo "Error:" & iReturn & " running SCP2."
End If

Open in new window

If you just want to launch SCP2 and then let the VBS script continue, then you can do:

Set oShell = WScript.CreateObject("WScript.Shell")
iReturn = oShell.Run("scp2 -u PRODFTP@10.182.188.88:.\In\*.inf  D:\ftp_in", 0, False)

Open in new window

In both cases I hid the SCP2 window, but that can be controlled by the 3rd parm.  See http://ss64.com/vb/run.html for the parms and options.

~bp
0
 
Peter KwanAnalyst ProgrammerCommented:
Please try the following

Dim WshShell, oExec
Set WshShell = WScript.CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("scp2 -u PRODFTP@10.182.188.88:.\In\*.inf  D:\ftp_in")

Open in new window

0
 
MezzutOzilAuthor Commented:
It works like a charm
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.