How to execute batch file from SQL Server using xp_CMDShell

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ira Sinha
    New Member
    • May 2010
    • 1

    How to execute batch file from SQL Server using xp_CMDShell

    I have created a batch file, which is using 7z command to encrypt and compress a file. The command in the batch file is
    7za -TZIP a [outputfilepath] [filepath] -p[password]

    I am able to run the batch file successfully from the command prompt, however when I try to execute the same file from the SQL Server using the xp_CMDShell, it gives me the following errors:
    Can not open file
    Access is denied.

    I am logged into the sql server with a Windows account, which is a member of the administrators group and has all the rights of sa on the sql server.

    Thanks
    Ira
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Try doing a DIR using the xp_cmdshell anc capture the result. See if you can see the batch file first before proceeding. If all is well on the file side, check your rights.

    Good Luck!!!

    ~~ CK

    Comment

    Working...