2

After updating Windows and SQL Server, xp_cmdshell is running slowly. We are running Windows Server 2016 with SQL Server 2016 SP1. We've fully updated SQL Server to SP2 CU8 with no change in behavior.

The performance of our Windows Server seems great. Also, we can run similar commands in batch with great speed. The performance of our SQL Server seems great as well.

I'm guessing that the issue is with each command needing a Windows environment, and maybe something changed recently with Windows? However, we don't see any issues on our virtual machines running the same version of SQL Server 2016.

We understand the security risks of having xp_cmdshell enabled and accept those risks.

Here is some code we use to test the speed on xp_cmdshell.

EXEC master..xp_cmdshell 'exit 0' --Simple, Open cmd, and exit
GO 25 --Run the command 25 times

I expect this code to run in under a second, however it's taking 15-20 seconds to run.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Zaulism
  • 21
  • 1
  • One thing I've found recently, on our server that is slow running xp_cmdshell, the xp_cmdshell create a security event (event viewer) that is an elevated token. On a second machine that doesn't have the issue, Elevated Token is 'No'. From what I read, this create a secondary profile, one elevated, one not. This is a possible culprit. Is there any way to control xp_cmdshell asking for an elevated token vs not? – Zaulism Aug 28 '19 at 16:38
  • Right click on SQL Management Studio and "Run as Administrator". Try to see if this bypass the elevated token. – Francesco Mantovani Aug 29 '19 at 19:56
  • Also, from what SQL Server version where you upgrading? – Francesco Mantovani Aug 29 '19 at 20:04
  • No change with running as admin. Upgraded from Sql Server 2016 to SP1 – Zaulism Sep 03 '19 at 15:11

0 Answers0