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 12345»»»

Using xp_cmdshell Expand / Collapse
Author
Message
Posted Sunday, December 28, 2003 12:00 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, January 18, 2013 11:03 AM
Points: 55, Visits: 60
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/hji/usingxp_cmdshell.asp


Post #19584
Posted Wednesday, January 07, 2004 5:27 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, April 14, 2014 7:51 AM
Points: 169, Visits: 111

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
Post #93845
Posted Wednesday, January 07, 2004 8:21 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued 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.




Post #94020
Posted Thursday, January 08, 2004 7:29 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC 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 

Post #94256
Posted Friday, January 09, 2004 5:38 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, April 14, 2014 7:51 AM
Points: 169, Visits: 111

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
Post #94333
Posted Friday, January 09, 2004 3:06 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued 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




Post #94497
Posted Friday, January 09, 2004 3:29 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC 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..

Post #94501
Posted Wednesday, January 24, 2007 1:36 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, July 18, 2013 8:59 AM
Points: 345, Visits: 235
what about xp_cmdshell with jobs?

i understand you can start a job from a different server, but can't
find any good examples.




_________________________
Post #339489
Posted Sunday, January 28, 2007 7:51 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued 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.


Post #340341
Posted Saturday, July 26, 2008 7:19 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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
Post #541380
« Prev Topic | Next Topic »

Add to briefcase 12345»»»

Permissions Expand / Collapse