$voice=New-Object -com "SAPI.SPVoice"
[string]$result=""
if([int](get-date).toString("HH") -ge 12)
{
    $result = "it is "+ [int](get-date).toString("hh") + " in the afternoon"
}
else
{
    $result = "it is "+ [int](get-date).toString("HH") + " in the morning"
}
[void]$voice.speak($result);

 

將上述script另存成副檔名為ps1的檔案(如 VoiceClock.ps1)
並且使用schtasks設定每小時執行一次
PS C:\> schtasks /Create /SC HOURLY /TN VoiceClock /ST 00:00:00 /TR "powershell d:\VoiceClock.ps1"

如此就可以每小時"聽到" 例如 "It is ten in the morning"等整點報時

[]目前假設有權限可正常執行Script檔案

arrow
arrow
    全站熱搜

    ayowu 發表在 痞客邦 留言(0) 人氣()