Trying to execute an .exe using xp_cmdshell , it runs the exe.
But my issue is the following, the exe has to be the same folder as a .txt file as the exe outputs to the txt file.
If i double click the exe the output goes to the .txt file. I also created a .Bat file that executes the .exe and it outputs
to the .txt file.
If i try and run either the .exe or the .Bat files from SQL they run but it doesn't output to the file.
EXECUTE xp_cmdshell '"D:\Run.BAT"'
EXECUTE xp_cmdshell "D:\Application.exe"
In my Results i get the following from running the .Bat
NULL
C:\Windows\system32>cd D:\
NULL
C:\Windows\system32>Application.exe
NULL
Add a line to the top of the BATch file that changes drive / folder to the "root" where the EXE and TXT file are? Then the EXE will run "in" that folder.
THE CD (or CHDIR if you prefer) command has an optional "/D" parameter which will change drive as well as folder.