How to convert this bat into vbs format?

Posted on 2012-09-20
Last Modified: 2012-09-25
This is using a batch format for some sftp operations to the remote server. Please see the command as follows:

    scp2 -u PRODFTP@\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?

Question by:MezzutOzil
    LVL 16

    Expert Comment

    by:Peter Kwan
    Please try the following

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

    Open in new window

    LVL 51

    Accepted Solution

    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@\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@\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 for the parms and options.


    Author Closing Comment

    It works like a charm

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
    This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
    Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now