Ghassan
Ghassan

Reputation: 351

Run .exe file from SQL Query

i am trying to open a .exe file from within an sql query or Job.

im using xp_cmdshell , it is enabled on the server

the .exe runs properly when i double click on it from my windows Explorer

but when i try to open it using xp_cmdshell it returns to me 1 row affected and the row is null.

the .exe file is supposed to delete all the content from a certain table. when i run the file from the windows explorer, the .exe deletes all the content of the above mentioned table, whereas when i try using xp_cmdshell the content of the table remain intact, which means the .exe file is not opened.

any ideas?? this is the code i'm using

exec master..xp_cmdshell 'C:\inetpub\wwwroot\Digital_Library_Shamaa\ShamaaConsoleIndexer\Publish\setup.exe'

i have added the permission Everyone to the folder containing the above .exe file and all its sub folders!

Upvotes: 1

Views: 7872

Answers (1)

Royi Namir
Royi Namir

Reputation: 148544

1) Run EXEC master..xp_cmdshell 'whoami' to see which user you're trying to run the exe file

2) Did you enable :

USE master
GO
EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE WITH OVERRIDE
GO
EXEC sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE WITH OVERRIDE
GO

3) Did you unblock the file ?

enter image description here

Upvotes: 0

Related Questions