Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9178331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:31:36+00:00 2026-06-17T17:31:36+00:00

I created the following stored procedure: CREATE PROCEDURE [dbo].[_StartWebcamStream] AS BEGIN declare @command varchar(200)

  • 0

I created the following stored procedure:

CREATE PROCEDURE [dbo].[_StartWebcamStream]
AS

BEGIN
    declare @command varchar(200)
    set @command = 'C:\startStream.bat'
    exec master..xp_cmdshell @command

END

for executing a the batch file startStream.bat. This batch contain the following code:

"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -I dummy -vvv rtsp://mycamaddress/live_mpeg4.sdp --network-caching=4096 --sout=#transcode{vcodec=mp4v,fps=15,vb=512,scale=1,height=240,width=320,acodec=mp4a,ab=128,channels=2}:duplicate{dst=http{mux=asf,dst=:11345/},dst=display} :sout-keep}

The batch file is launched correctly, but the query continues to run until the vlc is stopped.

What can I do for stopping the query letting the vlc running?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:31:37+00:00Added an answer on June 17, 2026 at 5:31 pm

    DISCLAIMER: Don’t run these examples in production!


    SQL Server watches all processes spawned by xp_cmdshell and waits for them to finish. to see that you can just run this statement:

    EXEC xp_cmdshell 'cmd /C "start cmd /K dir"'
    

    This starts a command shell that in-turn starts another command shell to execute the dir command. The first shell terminates right away after spawning the second (/C switch) while the second executes the “dir” and then does not terminate (/K switch). Because of that second lingering process, even though the process that SQL Server started directly is gone, the query won’t return. You cannot even cancel it. Even if you close the window in SSMS, the request continues to run. You can check that with

    SELECT r.session_id, t.text 
    FROM sys.dm_exec_requests r
    CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) t
    

    The NO_OUTPUT parameter does not help either:

    EXEC xp_cmdshell 'cmd /C "start cmd /K dir"', NO_OUTPUT;
    

    You will see the same “sticky” behavior.

    The only way to get rid of these is to restart the computer or manually kill the processes (requires taskmanager to be executed as administrator). Restarting the SQL Server service does not stop the spawned processes.


    As a solution you can use the SQL Agent. It has a “Operating System (CmdExec)” step type that you can use to run your program. You can create the job and then start it using sp_start_job.

    Either way, your process actually needs to finish at some point. Otherwise you will create a pile of process-“bodies” that will cause performance problems in the long run.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a stored procedure as following, CREATE PROCEDURE [dbo].[Access_GetDate] ( @Name varchar(255) )
I have following stored procedure: CREATE PROCEDURE testProc(IN p_idProject INTEGER) BEGIN DECLARE nowTime DATETIME;
I have the following stored procedure ALTER PROCEDURE [dbo].Test AS BEGIN CREATE TABLE ##table
I have the following insert stored procedure: CREATE Procedure dbo.APPL_ServerEnvironmentInsert ( @ServerEnvironmentName varchar(50), @ServerEnvironmentDescription
I have created the following stored procedure.. CREATE PROCEDURE [dbo].[UDSPRBHPRIMBUSTYPESTARTUP] ( @CODE CHAR(5) ,
I've created the following stored procedure: ALTER PROCEDURE [dbo].[ExampleSP] ( @SearchText NVARCHAR(4000), @ID INT
I have the following SQL Server stored procedure : BEGIN TRAN CREATE TABLE #TempTable
Good Evening All, I've created the following stored procedure: CREATE PROCEDURE AddQuote -- Add
I have a T-SQL stored procedure with the following parameters CREATE PROCEDURE [dbo].[SaveData] --
I have the following stored procedure to retrieve a new datetime: CREATE PROCEDURE [dbo].[GetTransactionTime]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.