0

i try open folder from my computer by run script in sql server

EXEC xp_cmdshell 'start C:\folder'

it folder not exixt and the process still execute then i do kill process

but it still KILLED/ROLLBACK

what to do now?

help!! michal

Venkataraman R
  • 12,181
  • 2
  • 31
  • 58
michal
  • 5
  • 3
  • 1
    If the external process (external to SQL Server) suddenly stops and does not correctly return execution to SQL Server and you try to kill the SQL Server process, then you will see this `KILLED/ROLLBACK` status and won't be able to remove this process from SQL Server until server restart, unfortunately. Good news is that nothing is actually executing, so you won't lose CPU time. That being said, it's not recommended to start cmd processes through SQL Server due to security reasons. – EzLo Apr 28 '20 at 08:44

1 Answers1

1

Open cmd:

tasklist /fi "IMAGENAME eq cmd.exe" /fi "SESSIONNAME eq Services" /v

get the PID of the running session (assuming it is 123456)

taskkill /PID 123456 /F

lptr
  • 1
  • 2
  • 6
  • 16
  • Iptr - thank you !! I did And that did solve the problem Just a question how do I know that this is exactly the CMD I run and not anyone that connected to the server or the SQL server itself can run? In short is it dangerous to stop it? – michal Apr 28 '20 at 09:52
  • you could check the command line of the process (eg. 123456) to be killed and verify that the parent process is sqlserver : `wmic process where "ProcessID=123456" get CommandLine, ParentPocessID` (assuming ParentProcessID=45678) `wmic process where "ProcessID=45678" get Name` – lptr Apr 28 '20 at 15:16