xp_cmdshell - vbscript

  • Hi,

    i tried to use xp_cmdshell in order to execute a vbscript from a trigger and it works, but i notice that trigger wait until the vbscript was terminated.

    i do some things into vbscript, so i can't wait until the end. There is a way to don't wait until the end, in practice, run vbscript in asynchronous mode???

    thanks in advance

    john

  • johnix76 (10/21/2014)


    Hi,

    i tried to use xp_cmdshell in order to execute a vbscript from a trigger and it works, but i notice that trigger wait until the vbscript was terminated.

    i do some things into vbscript, so i can't wait until the end. There is a way to don't wait until the end, in practice, run vbscript in asynchronous mode???

    thanks in advance

    john

    Can you provide some background on this please – what is the underlying requirement?


  • thanks for response.

    this is my need:

    when a user insert or update a record (an orders table) i need to send an email in real time(from/to gmail) in order to advise company agents if some quantity are not processed.

    can i do this in another way?

  • try to move the logic from vbscript to sql and use dbmail to send the email

    Gerald Britton, Pluralsight courses

  • g.britton (10/21/2014)


    try to move the logic from vbscript to sql and use dbmail to send the email

    That's definitely a better approach. While I do like xp_cmdshell, it probably isn't the right tool for the job in this instance. The procedure will wait for the xp_cmdshell to finish, which means your table operation is held in limbo until it completes and continues on. Using sp_send_dbmail will queue the email and continue with the procedure. It will likely be much faster than waiting for a VBS to execute.

  • Hi ,

    Can you send me the SQL script for calling a EXE from SQL server . I have tried to use xp_cmdshell from my stored procedure . But it is taking too long time to execute(more than 30 mins). Request you to send SQL and VB script.

    Thanks in advance.

    Senthil

  • senthil.k (3/16/2015)


    Hi ,

    Can you send me the SQL script for calling a EXE from SQL server . I have tried to use xp_cmdshell from my stored procedure . But it is taking too long time to execute(more than 30 mins). Request you to send SQL and VB script.

    Thanks in advance.

    Senthil

    create a SQL job, which uses a Operating System(CmdExec) step to run your executable.

    then it's off line and asyncronous.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

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

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