Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xp_cmdshell

Status
Not open for further replies.

rstum2005

Programmer
Jun 9, 2005
117
US
I cannot see the program when it is executed, but I can see it running in the task manager? It there a different way I should go about running an executible through SQL?

exec master.dbo.xp_cmdshell 'call c:\winamp.exe'


Oct31 == Dec25
 
Xp_cmdshell is "the way" to run executables in SQL..

However, SQL is a server program and runs in the background.. (as do all programs launched by sql..)

If you need to have the program run interactivly you will need to look for another option.. My money would be on the "AT command" or "psExec"..

Both are free.. The AT command is part of your OS and psexec can be downloaded from sysinternals..

Both offer an "interactive" mode..(interacts with the User logged on)

the pros and cons...
The AT command is a scheduling tool.. i.e At xoclock do somehting..

It is a bit of a pain to get all the switches correct and you need to be able to schedule things for a minimum of 1 min from now..

psexec... well it does'nt have too many downsides.. It can launch any program now.. You just have to download it..

It comes with 2 other very usefull tools.. pslist (show all running processes(programs)) and pskill (stop a process/program)



while you are there take a look around. My guess is that you will find tools to solve problems that you have had for years and just didn't know there was a solution for...


HTH

Rob
 
I did forget to mention..

You need xp_cmdshell to run each of the alteranaives mentioned..

i.e.
xp_cmdshell 'X:\tools\psexec \\pcname -i "c:\winnt\calc.exe"'

 
Rob,

Thanks for the great info man!

Ron.

Oct31 == Dec25
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top