Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


master.dbo.xp_cmdshell 'C:\WINDOWS\system32\notepad.exe'


master.dbo.xp_cmdshell 'C:\WINDOWS\system32\notepad.exe'

Author
Message
gerard flynn
gerard flynn
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
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
Marco V
Marco V
SSC-Addicted
SSC-Addicted (462 reputation)SSC-Addicted (462 reputation)SSC-Addicted (462 reputation)SSC-Addicted (462 reputation)SSC-Addicted (462 reputation)SSC-Addicted (462 reputation)SSC-Addicted (462 reputation)SSC-Addicted (462 reputation)

Group: General Forum Members
Points: 462 Visits: 569
it is not showing because the user who is executing it is SQL server and not you
Marco V
Marco V
SSC-Addicted
SSC-Addicted (462 reputation)SSC-Addicted (462 reputation)SSC-Addicted (462 reputation)SSC-Addicted (462 reputation)SSC-Addicted (462 reputation)SSC-Addicted (462 reputation)SSC-Addicted (462 reputation)SSC-Addicted (462 reputation)

Group: General Forum Members
Points: 462 Visits: 569
on a side note. why do you want to start notepad?
gerard flynn
gerard flynn
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
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
Marco V
Marco V
SSC-Addicted
SSC-Addicted (462 reputation)SSC-Addicted (462 reputation)SSC-Addicted (462 reputation)SSC-Addicted (462 reputation)SSC-Addicted (462 reputation)SSC-Addicted (462 reputation)SSC-Addicted (462 reputation)SSC-Addicted (462 reputation)

Group: General Forum Members
Points: 462 Visits: 569
ah oke BigGrin.. 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
Kenneth.Fisher
Kenneth.Fisher
Hall of Fame
Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)

Group: General Forum Members
Points: 3592 Visits: 2021
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
feleouet
feleouet
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search