0

I want to execute a command line utility using xp_cmdshell and return the results in CSV format for processing in a SQL Server table.

The command line with options/parameters:

tasklist /v /FO:CSV 

The SQL script line is:

EXEC xp_cmdshell 'tasklist /v /FO:CSV' 

The returned column names are:

Image Name, PID, Session Name, Session#, Mem Usage, Status, User Name, CPU Time, Window Title

It is important for me to take the "Window Title" info, but the window title always returns "N/A" when I run command line using xp_cmdshell. When I run code directly in Windows Command Prompt, (cmd.exe), it returns the "Window Title" information I require.

Compo
  • 36,585
  • 5
  • 27
  • 39
rkapukaya
  • 77
  • 1
  • 8

1 Answers1

0

SQL Server runs as a background service, and so has no desktop. And it can't see the "window title" of processes running in other sessions.

David Browne - Microsoft
  • 80,331
  • 6
  • 39
  • 67