使用Start-Service cmdlet來開啟尚未啟動的服務
-
2011年1月7日 上午 06:00
Dear Sir,
經由下列的Reference得知可以使用Start-Service cmdlet來開啟尚未啟動的服務,不知應如何修改以下的cmdlet或者撰寫script以達到以下的功能?
1.作業系統於凌晨01:00自動重新開機。
2.使用者(舉例來說:Administrator)自動登入。
3.登入十分鐘後自動開啟某特定服務。
Best Regards and Have a Nice Day
Chen Yi Chen
Reference:
What Can I Do With Windows PowerShell?Using the Start-Service CmdletStarting a Stopped Service
The Start-Service cmdlet is used for starting a service that is currently stopped. To start a service, simply call Start-Service followed by the service name (that is, the name of the service as stored in the registry):
Start-Service btwdins
Alternatively, you can add the -displayname parameter and start the service using the service display name, the name that appears in the Services snap-in:
Start-Service -displayname "Bluetooth service"- 已變更類型 Chen Yi Chen 2011年1月7日 上午 08:45
所有回覆
-
2011年1月7日 上午 07:35
1.作業系統於凌晨01:00自動重新開機。
建立一個 reboot.bat 內容如下,並排程每天01:00 執行
shutdown -r -t 0
2.使用者(舉例來說:Administrator)自動登入。
下載 Autologon ,執行後輸入要自動登入的號密碼
http://technet.microsoft.com/en-us/sysinternals/bb963905
3.登入十分鐘後自動開啟某特定服務。
先打開 powershell 執行 set-executionpolicy remotesigned
建立一個autostart.bat 內容如下,並建立捷徑放入步驟2的使用者功能表的啟動目錄
c:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe c:\powershell\autostart.ps1
再將將下列文字存成 autostart.ps1
#sleep 後面等於要等待的秒數
#$S=要啟動的服務
sleep 600
$S='tmlisten'
if ((Get-Service "$S").status -eq 'Stopped') {Start-Service "$S"} -
2011年2月9日 上午 06:34
1.作業系統於凌晨01:00自動重新開機。
建立一個 reboot.bat 內容如下,並排程每天01:00 執行
shutdown -r -t 0
2.使用者(舉例來說:Administrator)自動登入。
下載 Autologon ,執行後輸入要自動登入的號密碼
http://technet.microsoft.com/en-us/sysinternals/bb963905
3.登入十分鐘後自動開啟某特定服務。
先打開 powershell 執行 set-executionpolicy remotesigned
建立一個autostart.bat 內容如下,並建立捷徑放入步驟2的使用者功能表的啟動目錄
c:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe c:\powershell\autostart.ps1
再將將下列文字存成 autostart.ps1
#sleep 後面等於要等待的秒數
#$S=要啟動的服務
sleep 600
$S='tmlisten'
if ((Get-Service "$S").status -eq 'Stopped') {Start-Service "$S"}
Dear Sir,
我所建立的 reboot.bat 內容如下:
shutdown /r /t 30 /f /d p:4:1
Best Regards and Have a Nice Day
Chen Yi Chen

