|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Friday, January 18, 2013 11:03 AM
Points: 55,
Visits: 60
|
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 12:45 PM
Points: 168,
Visits: 97
|
|
xp_cmdshell is a very powerful tool. I have used it in the past to generate DOS FTP scripts and then execute the FTP command to FTP exported data to a client directly from a store procedure.
Pat Buskey
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Friday, January 18, 2013 11:03 AM
Points: 55,
Visits: 60
|
|
Yes Pat. I agree. xp_cmdshell can handle many automation jobs. I use it a lot in my environment. You mentioned FTP files using xp_cmdshell. One of my articles in the past talked about automating FTP using VBScript. I am not saying which method is better, just throw it out for your reference (watch out for line breaks): http://www.sqlservercentral.com/columnists/hji/usingvbscripttoautomatetasks.asp Cheers.
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, April 15, 2011 9:03 AM
Points: 49,
Visits: 75
|
|
Ok.. this SP.. its great.. but.. i am trying to call some BAT or EXE files.. and does not work... Is there somebody that use xp_cmdshell to call one BAT or EXE file.. ? for example: xp_cmdshell 'c:\Winnt\System32\calc.exe' Tnks
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 12:45 PM
Points: 168,
Visits: 97
|
|
Jose, I am not sure if this is the problem or not. Maybe it has to do with starting a program that requires user input? I tried to execute calc.exe and it did not work. However, I was able to exec .bat files as long I was not using the .bat file to open calc.exe If you look at the task manager, it does start the program, but you are denied access to it so maybe it's a permission problem. Hopefully someone will post a more definitive answer.
Pat Buskey
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Friday, January 18, 2013 11:03 AM
Points: 55,
Visits: 60
|
|
Jose, Pat is right. You will not see Calc started unless you are running SQL Server as a console application, because Calc is going to be a subprocess that has an interface and requires user interaction. xp_cmdshell is generally used to execute operating-system command. It is not designed to start applications which have a user interface.
If you start an application like Calc which has a user interaction via xp_cmdshell, xp_cmdshell will start your application, pass the control to your application, and wait indefinitely until it ends. Since you cannot close such an application manually while it is running in background, xp_cmdshell will never regain control from your application. You may have to kill the corrrespoding process manually via Task Manager-->Processes tab to terminate the application and allow xp_cmdshell to get the control back.
For more information, check out xp_cmdshell on BOL. Hope this helps. Haidong
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, April 15, 2011 9:03 AM
Points: 49,
Visits: 75
|
|
Yes.. Haidong.. I wasn't in my 5 sense.. jejeje... i was complicating my life.. jejeje.. The EXE file.. was running..(Not Calc.exe... my Application) but i want to see it.. to believe .. jejeje.. Tnks.. for your message..
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Tuesday, September 25, 2012 2:48 PM
Points: 345,
Visits: 234
|
|
what about xp_cmdshell with jobs?
i understand you can start a job from a different server, but can't find any good examples.
_________________________
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Friday, January 18, 2013 11:03 AM
Points: 55,
Visits: 60
|
|
You can consider the master/target server administration technique. You can also try dmo/smo to start a job from a different machine.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, December 07, 2011 1:46 AM
Points: 2,
Visits: 11
|
|
Hello all, I have a question Everytime i use xp_cmdshell on sql server 2000..cmd.exe porcess lefts open everytime.Once there was 80 cmd.exe process n task manager.how can i kill those processes after its done
|
|
|
|