How to run an app using Xp_cmdshell

  • Hi, I had a SP it's call a bat file with xp_cmdshell, when I execute SP: "exec master.dbo.xp_cmdshell 'C:\Comprime "aflores"',  the bat run perfectly, but de exe file "Comprime" dosn't work, when i run command line c:\Comprime "aflores", everything is ok....i don't know why dosn't work from SP, I need your help, please.....

     

    Thanks

     

  • Where is c:\Comprime? xp_cmdshell will execute on the SQL server machine in the context of the SQL server user account. If the exe is on some other machine (your desktop, for instance) it won't be found, or if the user context that SQL runs in can't see/execute something in the root of C: then the OS will stop you.

    Just guessing here...

     

  • It may be a case of not having the proper PATH. Here's a few eye opening commands from the 'old' DOS days that may help:

    • exec master.dbo.xp_cmdshell 'cd /d'
    • exec master.dbo.xp_cmdshell 'echp %PATH%'
    • exec master.dbo.xp_cmdshell 'set'

    RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."

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

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