你可能已经看到下面的脚本。现在,你用这段代码打开了一个消息窗体将同时随机播放了一段声音,是不是增加了一点娱乐吸引力。当用户结束消息窗体时声音将停止。
# find random WAV file in your Windows folder $randomWAV = Get-ChildItem -Path C:\Windows\Media -Filter *.wav | Get-Random | Select-Object -ExpandProperty Fullname # load Forms assembly to get a MsgBox dialog Add-Type -AssemblyName System.Windows.Forms # play random sound until MsgBox is closed $player = New-Object Media.SoundPlayer $randomWAV $player.Load(); $player.PlayLooping() $result = [System.Windows.Forms.MessageBox]::Show("We will reboot your machine now. Ok?", "PowerShell", "YesNo", "Exclamation") $player.Stop()
原文地址:Open MsgBox with Random Sound
本文链接: https://www.pstips.net/open-msgbox-with-random-sound.html
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!