INF: Programs Run Through Xp_cmdshell Have No User Interface

Article translations Article translations
Article ID: 323411 - View products that this article applies to.
This article was previously published under Q323411
Expand all | Collapse all

On This Page

SUMMARY

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.

MORE INFORMATION

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.

REFERENCES

SQL 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:
323527 How to use Windows Task Manager
For 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:
281340 PRB: File Compare Utility Fails to Run from Xp_cmdshell
If 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.

For a list of other similar known issues with xp_cmdshell, the following articles in the Microsoft Knowledge Base:
115184 INF: xp_cmdshell Does Not Retrieve User Input
152134 PRB: XP_CMDSHELL Does Not Work with XCOPY

Properties

Article ID: 323411 - Last Review: June 22, 2006 - Revision: 3.3
APPLIES TO
  • Microsoft SQL Server 2000 Standard Edition
  • Microsoft SQL Server 6.5 Standard Edition
  • Microsoft SQL Server 7.0 Standard Edition
Keywords: 
kbinfo KB323411

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com