Home Forums SQL Server 2005 T-SQL (SS2K5) master.dbo.xp_cmdshell 'C:\WINDOWS\system32\notepad.exe' RE: master.dbo.xp_cmdshell 'C:\WINDOWS\system32\notepad.exe'

  • 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]