如何停止處於stopping狀態的windows service(SC)

來源:互聯網
上載者:User

測試過程中,需要啟動和停止windows service,有時候會出現服務處於stopping或者starting的狀態,但是,在services介面中,start service/stop service已經處於灰色不可操作狀態,用命令列的形式net start/stop servicename也無濟於事。停止服務的方法就是關掉這個進程,但是很多時候無法確定是哪個進程與之相關。在命令列中我們可以使用sc queryex servicename這個命令來獲得該服務的相關資訊。

For example,

Run 'sc queryex OLSLADTservice' in command prompt

The output is below,

SERVICE_NAME: OLSLADTservice
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 4  stopping
                                (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0
        PID                : 4652
        FLAGS              :

Then we can use 'taskkill /PID 4652 /F' in command prompt to kill the process. /F means 'kill forcely'.

sc功能很強大,具體可以參考下面的兩個連結:

http://bartdesmet.net/blogs/bart/archive/2004/10/16/438.aspx

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/sc.mspx?mfr=true (more info on sc.exe)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.