call executable with xp_cmdshell from procedure

  • The following indicates that xp_cmdshell works like expected:

    declare @sqlcmd varchar(200)

    SET @sqlcmd = 'dir d:\runtime\SomeExec.exe'

    EXEC master.dbo.xp_cmdshell @sqlcmd

    giving output that indicates the .exe is in the right place

    The executable runs from a cmd box just fine..

    declare @sqlcmd varchar(200)

    SET @sqlcmd = 'd:\runtime\SomeExec.exe'

    EXEC master.dbo.xp_cmdshell @sqlcmd

    would supposedly fire the executable, but nothing happens, no error is returned, nada

    What am I missing?

  • What is supposed to happen? What your expected result from executable?

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • details are in order, i think.

    are you really just running 'dir d:\runtime\SomeExec.exe' (directory!) or are you EXECUTING 'd:\runtime\SomeExec.exe'

    how do you know "nothing" happened?

    what does the executable do?

    does it return any results via a command line?

    does the program close itself automatically after running?

    is it possible the program raises a messagebox/Ok that cannot be interacted with ?

    If you were to run notepad via cmdShell, an instance of it would sit open in the processes, but there would be no user interaction possible to close it...you'd have to kill the process .

    declare @sqlcmd varchar(200)

    SET @sqlcmd = notepad.exe'

    EXEC master.dbo.xp_cmdshell @sqlcmd

    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!

  • Lowell (6/6/2012)


    details are in order, i think.

    are you really just running 'dir d:\runtime\SomeExec.exe' (directory!) or are you EXECUTING 'd:\runtime\SomeExec.exe'

    The 'dir' version just made clear that xp_cmdshell is working

    how do you know "nothing" happened?

    The executable creates a table in a database and loads data into the table..

    does it return any results via a command line?

    Everything works fine from a command line

    does the program close itself automatically after running?

    Runs in the background..

    is it possible the program raises a messagebox/Ok that cannot be interacted with ?

    No, no input required..

    From what I gathered It is required to start up a cmd box in the code itself:

    http://binaryworld.net/Main/CodeDetail.aspx?CodeId=4014

    It is not helping either by using a . bat file though

Viewing 4 posts - 1 through 3 (of 3 total)

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