• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 686
  • Last Modified:

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,
0
MezzutOzil
Asked:
MezzutOzil
1 Solution
 
Peter KwanCommented:
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
 
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
 
MezzutOzilAuthor Commented:
It works like a charm
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now