SQL
How to give any window command from sql like opening of
September 6th, 2015 4:43pm

checkout this video if useful or answers your query

https://www.youtube.com/watch?v=o_ljf5X4XtU

or 

xp_cmdshell 'dir c:/windows'

run from sql management studio > new query>  returns contents from C:\windows

Free Windows Admin Tool Kit Click here and download it now
September 6th, 2015 9:03pm

Hi j.kumar,

In SQL Server, the xp_cmdshell command is used to spawn a Windows command shell and passes in a string for execution.

Based on my test, I have used the following command in SSMS for testing purposes:
xp_cmdshell 'C:\WINDOWS\system32\notepad.exe'
When we execute this, it just keeps executing no notepad opens. But if you open task manager you can see the notepad running if you kill this process the query stops.

Based on my research, we cannot open the notepad via this query, this is by design. Because 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.

Reference:
INF: Programs Run Through Xp_cmdshell Have No User Interface

Thanks,
Katherine Xiong

September 7th, 2015 12:02am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics