Hello,
I have a simple and short batch file I am trying to execute from SQL server. The SQL database I am connected to is my local instance. The script I am using is as below:
EXECUTE [master].[dbo].[xp_cmdshell] 'C:\Users\Jdoe\Desktop\Test.bat'
The batch file is located at the path listed above and contains the below:
SchTasks /query /fo csv > I:\Schedtask.txt /v /s reports.xyz.org
The above command line code connects to a remote machine and gets the list of all scheduled tasks. Please note that executing the batch file by double-clicking on the icon works without issues. When I try however to run the SQL listed above, I get the below:
output
NULL
C:\Windows\system32>SchTasks /query /fo csv /v /s reports.xyz.org 1>I:\Schedtask.txt
The system cannot find the path specified.
NULL
What am I doing wrong. I am expecting the SQL to execute de batch file which should create a output file at the specified location but it doesn't.
Thanks for helping