Can I run a VBS script in a scheduled SQL Job?

  • Hi

    I have a vbs script that runs fine in the command line(It uses CuteFTP to upload a file )
    I tried to run in a scheduled SQL job it gets no errors but produces no output

    I tried to put "cscript c:\scripts\beacon.vbs" in a .bat file and run the .bat in CMDexec

    Figuring I could use Active X script ????

    any ideas would be great

    Thaks
    Joe

  • jbalbo - Friday, July 6, 2018 11:17 AM

    Hi

    I have a vbs script that runs fine in the command line(It uses CuteFTP to upload a file )
    I tried to run in a scheduled SQL job it gets no errors but produces no output

    I tried to put "cscript c:\scripts\beacon.vbs" in a .bat file and run the .bat in CMDexec

    Figuring I could use Active X script ????

    any ideas would be great

    Thaks
    Joe

    Why don't you just set a task in Task Scheduler at the operating system to run it whenever you need it?

    I think using the SQL Server Agent to run stuff that don't belong to the SQL instance is bad practice.

    Greetings

  • Thanks
    My idea was  step one moves a file, then 2 runs the ftp script , then if it fails, for some reason, I could get a notice

  • Alejandro Santana - Friday, July 6, 2018 11:49 AM

    I think using the SQL Server Agent to run stuff that don't belong to the SQL instance is bad practice.

    I have diametrically the opposite opinion.  What makes you say that it's a bad practice?

    --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)

  • jbalbo - Friday, July 6, 2018 12:31 PM

    Thanks
    My idea was  step one moves a file, then 2 runs the ftp script , then if it fails, for some reason, I could get a notice

    Does your SQL Server agent actually have access to the directory where the script is?

  • Yes I just checked agin

  • Jeff Moden - Friday, July 6, 2018 1:20 PM

    Alejandro Santana - Friday, July 6, 2018 11:49 AM

    I think using the SQL Server Agent to run stuff that don't belong to the SQL instance is bad practice.

    I have diametrically the opposite opinion.  What makes you say that it's a bad practice?

    +1 🙂

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Jeff Moden - Friday, July 6, 2018 1:20 PM

    Alejandro Santana - Friday, July 6, 2018 11:49 AM

    I think using the SQL Server Agent to run stuff that don't belong to the SQL instance is bad practice.

    I have diametrically the opposite opinion.  What makes you say that it's a bad practice?

    I believed that running stuff that didn't belong to the instance of SQL server in the long run would be tedious, but after reading his answer i told to myself that one indeed pays more attention to the SQL server agent than the server task scheduler, and it's as he says. 

    My idea was step one moves a file, then 2 runs the ftp script , then if it fails, for some reason, I could get a notice 

    Its more effective about handling if it fails or if it succeeds.

    And if migrating the SQL Instance you would be thinking more of the jobs than the task scheduler tasks.

  • jbalbo - Friday, July 6, 2018 1:31 PM

    Yes I just checked agin

    My idea was step one moves a file, then 2 runs the ftp script , then if it fails, for some reason, I could get a notice 

    You have a script that makes the whole task? If so, try to make a .bat and with that .bat call the main task.
    example: starttask.bat  > maintask.bat.

    if that doesn't work you could try using xp_cmdshell from SQL Server and putting it in a job like you said earlier.
    https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/xp-cmdshell-transact-sql?view=sql-server-2017

Viewing 9 posts - 1 through 8 (of 8 total)

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