0

I'm using MS SQL server 2014 web edition.

I created a maintenance plan, and I used a T-SQL statement task to execute xp_cmdshell to execute a batch file.

T-SQL statement:

exec master.dbo.xp_cmdshell 'Path\XX.bat'

When doing so, I get success. But the batch file isn't working. (it should compress the .bak files using winrar). The batch file works fine when executed manually. The login I'm using is "sa" has sysadmin role, and the owner of the master database.

I checked if I can reach the path and turns out I can cause I can see the files in there, using this:

EXEC master.dbo.xp_cmdshell 'dir X\XXX'
TT.
  • 15,774
  • 6
  • 47
  • 88
  • 3
    Add `echo test > test.txt` to your .bat to verify that it's firing. Check that you can reach the location of the .bak files from `xp_cmdshell` too. – Aaron Dietz Jul 31 '17 at 19:59
  • Check priviliges for SQL Server service account. – Lukasz Szozda Jul 31 '17 at 20:03
  • Redirect output from the batch file to a file: `exec master.dbo.xp_cmdshell 'Path\XX.bat > Path\outp.txt'` and see what that tells you. – TT. Jul 31 '17 at 20:05

0 Answers0