February 23, 2011 at 4:38 am
i want to be able to call a exe from mssql my program is call scramble.exe held in c:\test
i have used the following command in sql for testing purposes
*master.dbo.xp_cmdshell 'C:\WINDOWS\system32otepad.exe'*
when you execute this it just keeps executing no notepad opens but if you open task manger you can see the notepad running if you kill this process the query stops
can any one help em with this ta Gerard
February 23, 2011 at 4:57 am
it is not showing because the user who is executing it is SQL server and not you
February 23, 2011 at 5:07 am
on a side note. why do you want to start notepad?
February 23, 2011 at 5:14 am
it not notepad i am running its a c# exe to scramble db
my example was notepad when you run that command it put notepad into task manager
all i an to do is Run external programs from SQL Server stored procedures
is this possible or is there another way of doing it
February 23, 2011 at 5:21 am
ah oke :D.. you never know
as for the result it doesnt matter if its notepad or minesweeper or whatever. But whatever you can make sure it does end. In case of notepad it will keep on running. but if you have some kind of program who is doing a batch of executions but ends then it will be no problem.
For the issue that you wont see it. guess you the only solution i can think of is building in logging with the C program
February 23, 2011 at 8:29 am
The reason notepad keeps running is that it hasn't been told to close. You've opened it in a shell that can't get any further responses from you so it just sits there waiting for something to tell it what to do. As far as getting data back, you should be able to if your program writes something back out. For example run a xp_cmdshell 'dir c:\' and you will get back the results from the directory. DIR is what I usually use for testing purposes btw. And of course as Marco said if you set up your program to log it will work just fine.
In fact here is another command if you want to see external evidence that your code ran successfully. xp_cmdshell 'dir c:\ > c:\test.txt' Important note though, both C drives are the C drive on the server, not your local machine.
Kenneth
Kenneth FisherI was once offered a wizards hat but it got in the way of my dunce cap.--------------------------------------------------------------------------------For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/[/url]Link to my Blog Post --> www.SQLStudies.com[/url]
October 9, 2013 at 5:53 am
hello,
I was using DTS in SQL2000 tu run aplications form SQLServer (Iexporer.exe, for example).
How can I do the same thing (without DTS) with SQL 2008 ? When I try that on sql2008 :
EXEC xp_cmdshell 'Echo Hello' : it works
EXEC xp_cmdshell 'c:\progra~1\intern~1\iexplore.exe' : it keeps running, doesn't open IE
I have to restart sqlserver to end the running of xp_cmdshell...
What is the problem ? and the solution ... ?
Thanks for you help.
Fabienne
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply