iT邦幫忙

2024 iThome 鐵人賽

DAY 27
0

事由:原本由Windows net命令來start / stop的Service,會造成該Service的Status為Stopping,久久無法變回Stopped,只能強行kill。
參考:https://4it.com.au/kb/article/how-to-kill-a-windows-service-which-is-stuck-at-stopping/
取得PID:sc queryex servicename
刪除Service:taskkill /f /pid [PID]
以Service Name為key進行強制刪除,例:

taskkill /F /FI "SERVICES eq JBossEAP7"

(在Windows的CMD或PowerShell是不分大小寫)

Windows目前是以sc指令取代舊版net,由PowerShell的 的Get-Service / Start-Service / Stop-Service / Restart-Services等與sc來管理服務

  • 尚有New-Service, Set-Service, Resume-Service, Suspend-Service
    所以之後啟動Service就不要再使用net,改用sc指令或PowerShell
    參考:https://superuser.com/questions/315166/net-start-service-and-sc-start-what-is-the-difference
  1. net is older – from the days of MS-DOS and OS/2, in fact.
    sc only appeared with Windows NT (not sure which version).
  2. net can only start, stop and pause services.
    sc has more advanced controls, can query state, create and delete services, change their configuration and security: sc config beep start= demand
  3. net only works locally.
    sc can be used over the network: sc \snow start rpcapd
  4. net accepts display names: net start "Windows Firewall"
    sc always requires a service name: sc start SharedAccess

上一篇
在Windows安裝OpenSSH Server作為SFTP Server
下一篇
PowerShell五四三
系列文
作業系統的專武30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言