Article ID: 323411 - View products that this article applies to.
This article was previously published under Q323411
This article has been archived. It is offered "as is" and will no longer be updated.
If you run a program through the xp_cmdshell extended stored procedure, the program only runs in the background. The xp_cmdshell extended stored procedure does not display the user interface of the programs that run in its context. If an application that is run through xp_cmdshell does needs user interaction from a user interface (for example, the application tries to create a dialog box or a message box that needs user input) it will stop responding because it is waiting for input. However, xp_cmdshell will never display the user interface; therefore, the user cannot provide any input.
The xp_cmdshell stored procedure is typically included in SQL scripts to run operating system commands. It is not designed to start applications that have a user interface that interact with a user.
If you use xp_cmdshell to start an application (for example, Notepad) that has a user interface, xp_cmdshell will start your application, pass the control to your application, and then wait indefinitely until it ends. Because you cannot close such an application interactively while it is running in the background, xp_cmdshell never regains control from your application.
For xp_cmdshell to regain control, you may have to kill the corresponding process of your application manually with Task Manager. Note that you must continue with caution when you end a process. If you quit a program in this manner, data that has not been saved will be lost. If you end a system process, a system component may no longer function properly.
REFERENCESSQL Server Books Online; topic: "xp_cmdshell"
For more information about killing a process with Task Manager, click the following article number to view the article in the Microsoft Knowledge Base:
323527For some programs that require a Winstation to run, you can also use NUL console as a workaround. For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/323527/ )How to use Windows Task Manager
281340If you must start and access an application that has a user interface remotely, use Remote Desktop Connection or Terminal Services. They are designed for this purpose.
(http://support.microsoft.com/kb/281340/EN-US/ )PRB: File Compare Utility Fails to Run from Xp_cmdshell
For a list of other similar known issues with xp_cmdshell, the following articles in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/115184/EN-US/ )INF: xp_cmdshell Does Not Retrieve User Input
(http://support.microsoft.com/kb/152134/EN-US/ )PRB: XP_CMDSHELL Does Not Work with XCOPY