Using VBScript to Automate Tasks

  • The following questions are for script#2.

    1) When the FTP script is run, what does the '-s' represent, send a single file?

    2) Is there a way to make the DOS screen freeze when the FTP script is being run?  I've tried 'pause', 'prompt', 'echo', etc. but nothing seems to work.

    3) How can a logfile be created when the FTP script is run?  I've used the Chr to put the ascii '>>' characters in but a logfile is not created.

    Thanx!     Warren

              

  • I need this funcionality, but I have not done VBScript with SQL Server before.

    Where do you put this code? Do I bring up SQL Mgmt Studio and then what?

    Can you point me to a resource?

    Thanks. CW

  • Pretty cool neat VBS

    I am playing with them already

    I suppose SSIS/Batch can work equally well for the same thing

    SQLServerNewbieMCITP: Database Administrator SQL Server 2005
  • You can put it in a Sql Server Agent job. Create a new job, go to steps, and pick ActiveX script from the dropdown.

  • Delete files in a folder that are certain days old script is worth keeping in personal briefcase. Thanks for a good article.

    SQL DBA.

  • Outstanding primer on VBS and the FSO... well done.

    I don't know if I missed it in the article, but for anyone that hasn't used it before, you should have said something to the effect that you can write the code using any text editor, mention that the files can be saved like any text file, and which extensions the operating system expects for VBS files (.vbs or .scr??? Not sure on .scr because I always use .VBS). It would also be handy to empasize a bit that the scripts can be called from any .bat file.

    Again, outstanding job and good documented examples.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

  • Great point!

    Thanks a lot Jeff for the compliment 🙂

  • Haidong Ji, This is an excellent article and I appreciate the information.

    I do have one question though, I have worked with a variety of technologies, but I have not yet used VBS. Why would you want to implement it this way instead of making an actual application or writing it in sql with use of xp command shell?

    ---
    Timothy A Wiseman
    SQL Blog: http://timothyawiseman.wordpress.com/

  • Heh... I can explain that... since it's a "script", it may not be subject to the normal "code release" steps within a company, it's callable from DTS or SSIS, it's available on every Windows machine, and it's free...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

  • How does the script for deleting old files differ from the Deleting old files in the Maintenance plan?

    thanks

  • It does the same thing, as far as I can tell.

  • Haidong,

    Thanks for posting this article. I've never done any scripting or programming other than SQL. I had a task in my assigned "To Do" list at work that required automating some backup and log deletes. I've been putting it off because I didn't know how to do it other than write some SQL with xpcmdshell and I still wasn't sure exactly how to accomplish it. This article popped up in my email and now it's done! Thank you for knocking something of my tasklist and helping me get over the fear of vbscript!

  • Thanks Jeff. None of those are issues in my situations, but they make perfect sense for reasons someone might need to use this.

    ---
    Timothy A Wiseman
    SQL Blog: http://timothyawiseman.wordpress.com/

  • Thanks Timothy... That's why I normally don't use VBS scripts... I can do almost everything with T-SQL. 🙂

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

  • Nice article...but -

    I can't help but ask - why use VBScript when you can use an actual full-featured language? You know - something with actual types, error-handling, etc...?

    I mean - in the old days where putting together a full fledged VB6 was a PITA, okay, I could see it. But simple console apps are just as simple to put together, and are oh so very much cleaner to put together....

    All right fine - I like VBScript too....But it's almost invariably garbage code because it allows itself to have no form whatsoever....

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

Viewing 15 posts - 16 through 30 (of 40 total)

You must be logged in to reply to this topic. Login to reply