大家都知道開啟和停止服務(wù)要用命令net start servicename和net stop servicename吧
但是怎么才能在命令行下設(shè)置一個服務(wù)的啟動狀態(tài)呢?比如說禁用它?
系統(tǒng)自帶的東東里可能有,但是我沒研究過,我只說pstools里帶的psservice命令
在命令行下輸入psservice/?命令可以看到使用說明:
Usage: psservice [\\Computer [-u Username [-p Password]]] <cmd> <optns> Cmd is one of the following: query Queries the status of a service config Queries the configuration start Starts a service stop Stops a service restart Stops and then restarts a service pause Pauses a service cont Continues a paused service depend Enumerates the services that depend on the one specified find Searches for an instance of a service on the network
這是psservice命令的參數(shù)列表,但是今天我們用到的是這個列表里沒有出現(xiàn)的一個參數(shù): setconfig
比如說要禁用Uninterruptible Power Supply服務(wù)(UPS),我們知道它的服務(wù)名稱是UPS,那么只要輸入以下命令:
psservice setconfig ups disabled
就可以把這個服務(wù)禁用掉了
其中的disabled可以換成auto和demand,分別是對應(yīng)自動和手動
|