Running an external exe file using XP_CMDSHELL

  • It should work as you've pasted in. I get a command string of:

    "C:\Program Files\KeyGen\vgenlic.exe" pippo pppppp 3

    If that runs from a command prompt, it should work. I'd perhaps grab the return code from a execution (exec @return = xp_cmdshell...") and see what's there. Are you sure the SQL Service account can run this? rights to the folder/file?

  • In SQL 2005, running xp_cmdshell is turned off by default. Have you turned it on?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Thanks for the reply

    I already used xp_cmdshell with other commands and always worked fine without problems.

    I already tried to have back the return code from the execution and if I write just the first two parameters it seems that the command is executed correctly but if if I add the third one the command always fails.

  • Have you tried copy-and-pasting the value of the @cmdstr variable into the shell and running it that way? Or have you typed it in yourself? (I see that you tested it, I'm asking about methodology here.)

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

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

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