How do I schedule a VBS file in SQL Agent?

  • I have a VBS file that opens up a Web page that runs fine in the command prompt and when I double click it, but when I try to schedule the CmdExec SQL Agent Job in SQL Server 2005 sp2, I get this error:

    "The process could not be created (reason: %1 is not a valid Win32 application). The step failed"

    What I specify in the box is "C :\test.vbs"

    I tried setting up a proxy account with admin permissions to the box and it didn't help.

  • Hello,

    I am not sure How to do this in SQL server,But In our environment we are using batch file to call vbs file and executing that batch file using windows ADD shedule Tasks.That worked for us.

    Regards,

    Sireesh

  • If I had gone with the Windows task scheduler route it would have saved me a lot of time. My thinking was that it would help if all the scheduled processes were in the same place, and this would have been the first Windows scheduled task.

    I eventually found the solution. I had to write this

    CScript.exe /NOLOGO "C:\test.vbs"

  • You create a Job in SQL Agent, then Create a new Job Step.

    Under the "Step Type" dropdown, select "ActiveX script".

    There you will find options for running your VBS.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • I tried running the VBS code directly as an ActiveX Script and it didn't work. I read a discussion thread from someone trying to do exactly what I was trying to do and he eventually gave up on the ActiveX technique without finding a solution.

    The other issue I didn't mention is that I want reusable code that I can use to execute other Web pages, so it makes sense to abstract this into a VBS file that takes a URL as an argument.

    I do have this working now and it seems to work great.

  • OK, that's cool.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Have you tried this:

    create a job and run it as CMDEXEC. The command to use is

    cmd /c /x "Path of the VBS"

    Or

    Call it like 'wscript C:\temp\file.vbs'

    MJ

Viewing 7 posts - 1 through 6 (of 6 total)

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