SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 EXEC XP_CMDSHELL 'exe'
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Gigabyte
Starting Member

India
30 Posts

Posted - 11/09/2012 :  01:09:13  Show Profile  Reply with Quote
exec xp_cmdshell 'exe file path'

This is running forever ...any help I could get??

Thanks in advance.


GIGABYTE+

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 11/09/2012 :  06:56:57  Show Profile  Reply with Quote
If the executable that you are running displays a window or is expecting any user input, it will not terminate - you will need to kill it from the task manager.

If that is not the case: are you able to run the exe from a command window successfully? If you are, then do some experimentation - start with a simple example: exec xp_cmdshell 'dir c:\' and see if that works for you.
Go to Top of Page

Gigabyte
Starting Member

India
30 Posts

Posted - 11/09/2012 :  07:20:21  Show Profile  Reply with Quote
I am using this and it is running for ever ..

exec xp_cmdshell 'C:\Windows\System32\calc.exe'

Also there will be no use if I run this and stop it using task manager.

Is it possible to open exe program and stop the query execution automatically.


GIGABYTE+
Go to Top of Page

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 11/09/2012 :  07:27:46  Show Profile  Reply with Quote
quote:
Is it possible to open exe program and stop the query execution automatically.

This is not possible. xp_cmdshell operates synchronously, so control is not returned to the T-SQL session until the command is completed.

When you use xp_cmdshell, commands are run in the background. You would not see the calculator window on your screen. You can see calc.exe in task manager (be sure to check the box that says "Show processes from all users" in the task manager).

The bottom line is that xp_cmdshell should NOT be used to run programs that require user input to proceed or require user input to terminate.
Go to Top of Page

Gigabyte
Starting Member

India
30 Posts

Posted - 11/09/2012 :  07:38:03  Show Profile  Reply with Quote
Thank you so much Sunitabeck.

Thanks for quick responses.

GIGABYTE+
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.33 seconds. Powered By: Snitz Forums 2000