Of how to use PowerShell?
Inspired by q&a: How can I play mp3 from the command line in Windows 7?
 
A bit shocked, offered answers that boil down to 'download and install additional software'... and so the system is already under 20Gbsome shit something useful, which is called by the operating system... sorry, it slipped.
 
When in Windows XP used for this task a simple utility mplay, though the GUI but the task scheduler normally starts, but in Windows 7 removed it and even sndrec32. Start wmplayer monstrously feel stupid, so you have to turn to scripting languages.
 
Examples of one-line scripts on vbs for windows scripting host you can dig up on the Internet, here is a simple example:
By the way, it's a miracle that the code has earned on windows 7 as compared to windows xp a number of activex objects are gone (like WMPlayerClass) and no one knows when it will disappear or how to change the SAPI class, and this is not the case, a microscope to hammer nails. Therefore, this decision is considered wrong and not logical, and ActiveX is dying slowly, it is logical to kill .NET environment.
 
I tried to solve the problem of new-fangled PowerShell (can't cook, but specially rummaged in the documentation), my hair stood on end from how it combines great ideas with horrible implementation. For example you are not able to run the script from the command line without creating and without signing the file (I understand, safety is paramount, as a result of the questions, whether to use it).
 
Here is a simple code:
 
But that's the way:
 
Tried to use redirection:
 
And without use -command -:
 
Okay, I give up, trying to allow non-signed scripts (run under privileged shelom):
 
 
if respected Hebraist to solve this problem is simple and racially the right way? As I understand it, the last test showed that epic certificates are not worth starting, because the problem is somewhere else.
 
UPD TheBits and Paul: Elephant I did not notice, the script completes do not play the game, and run the code from command line, you can arrange with significant groupings and the symbol &:
 
UPD2 based On number of comments: the Final decision itself may be subject to the automatic determination of the duration of the file and the exception variable $s:
Article based on information from habrahabr.ru
A bit shocked, offered answers that boil down to 'download and install additional software'... and so the system is already under 20Gb
When in Windows XP used for this task a simple utility mplay, though the GUI but the task scheduler normally starts, but in Windows 7 removed it and even sndrec32. Start wmplayer monstrously feel stupid, so you have to turn to scripting languages.
Examples of one-line scripts on vbs for windows scripting host you can dig up on the Internet, here is a simple example:
Set oVoice = CreateObject("SAPI.SpVoice")
 
set oSpFileStream = CreateObject("SAPI.SpFileStream")
 
oSpFileStream.Open "c:\Windows\Media\tada.wav"
 
oVoice.SpeakStream oSpFileStream
 
oSpFileStream.Close
 
By the way, it's a miracle that the code has earned on windows 7 as compared to windows xp a number of activex objects are gone (like WMPlayerClass) and no one knows when it will disappear or how to change the SAPI class, and this is not the case, a microscope to hammer nails. Therefore, this decision is considered wrong and not logical, and ActiveX is dying slowly, it is logical to kill .NET environment.
I tried to solve the problem of new-fangled PowerShell (can't cook, but specially rummaged in the documentation), my hair stood on end from how it combines great ideas with horrible implementation. For example you are not able to run the script from the command line without creating and without signing the file (I understand, safety is paramount, as a result of the questions, whether to use it).
Here is a simple code:
$s=new-Object System.Media.The SoundPlayer;$s.SoundLocation='C:\Windows\Media\tada.wav';$s.Play();But that's the way:
powershell -Command $s=new-Object System.Media.The SoundPlayer;$s.SoundLocation='C:\Windows\Media\tada.wav';$s.Play();Tried to use redirection:
echo $s=new-Object System.Media.The SoundPlayer;$s.SoundLocation='C:\Windows\Media\tada.wav';$s.Play(); | powershell -command -And without use -command -:
echo $s=new-Object System.Media.The SoundPlayer;$s.SoundLocation='C:\Windows\Media\tada.wav';$s.Play(); | powershellOkay, I give up, trying to allow non-signed scripts (run under privileged shelom):
powershell Set-ExecutionPolicy Unrestrictedpowershell c:\a.ps1UPD TheBits and Paul: Elephant I did not notice, the script completes do not play the game, and run the code from command line, you can arrange with significant groupings and the symbol &:
powershell -Command "&{$s=new-Object System.Media.The SoundPlayer; $s.SoundLocation='C:/Windows/Media/tada.wav'; $s.Play(); Sleep -Seconds 9}"UPD2 based On number of comments: the Final decision itself may be subject to the automatic determination of the duration of the file and the exception variable $s:
powershell -Command (new-object Media.SoundPlayer "C:\Windows\Media\notify.wav").playsync();
Комментарии
Отправить комментарий