Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

master.dbo.xp_cmdshell 'C:\WINDOWS\system32\notepad.exe' Expand / Collapse
Author
Message
Posted Wednesday, February 23, 2011 4:38 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, November 19, 2012 10:16 AM
Points: 2, Visits: 100
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
Post #1068140
Posted Wednesday, February 23, 2011 4:57 AM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Thursday, March 27, 2014 2:51 AM
Points: 462, Visits: 517
it is not showing because the user who is executing it is SQL server and not you
Post #1068146
Posted Wednesday, February 23, 2011 5:07 AM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Thursday, March 27, 2014 2:51 AM
Points: 462, Visits: 517
on a side note. why do you want to start notepad?
Post #1068150
Posted Wednesday, February 23, 2011 5:14 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, November 19, 2012 10:16 AM
Points: 2, Visits: 100
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
Post #1068154
Posted Wednesday, February 23, 2011 5:21 AM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Thursday, March 27, 2014 2:51 AM
Points: 462, Visits: 517
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
Post #1068157
Posted Wednesday, February 23, 2011 8:29 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 6:13 AM
Points: 3,436, Visits: 1,682
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 Fisher
I strive to live in a world where a chicken can cross the road without being questioned about its motives.
--------------------------------------------------------------------------------
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Link to my Blog Post --> www.SQLStudies.com
Post #1068310
Posted Wednesday, October 09, 2013 5:53 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, October 09, 2013 5:47 AM
Points: 1, Visits: 0
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
Post #1503036
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse