Today at work, I wanted to know how to create in Windows 7 a simple icon/shortcut to play a sound on the background, without having any media player opening (in my case, I wanted to play a rimshot sound whenever a colleague would say a relatively bad joke).
I searched for a long time on the web, but I wasn't able to find a simple solution to do this (I found a large amount of webpages helping users to remove ads sounds running on the background, but nothing that really served my purpose).
I then found a post from Aug 11, 2008 posted on one of my favourite blogs I check several times a day: How-To-Geek!!! This great article was about how to "Create a Shortcut or Hotkey to Mute the System Volume in Windows".
To do so, they used something called NirCmd (available here: http://www.nirsoft.net/utils/nircmd.html).
And while checking this tool's documentation, I found exactly what I was looking for: the mediaplay command.
Here is the detail about this mediaplay command:
*mediaplay [play time] [audio file]*
*Plays the specified audio file (.mp3, .wav, and so on) for the specified number of milliseconds.*
I then decided to share what I did with you guys, and signed up to create my first topic here.
So here is what you have to do to create a simple shortcut/icon that plays a rimshot sound.
Download "NirCmd" from the website I mentioned above and save it on
Search on the web or on your computer for the audio file you want to
play ("Rimshot.mp3" in this example). You can also download a
particular icon for this shortcut ("Rimshot.ico" in this example).
Copy the "NirCmd.exe", "Rimshot.ico" and "Rimshot.mp3" files in a
folder where you have permissions to write data (D:\ in this
Create a shortcut to the newly copied "NirCmd.exe" and type the
following in the Target field:
"D:\nircmd.exe" mediaplay 1746 "D:\Rimshot.mp3"
NB: 1746 refers to the length of the "Rimshot.mp3" sound in milliseconds. I used Audacity to get this number.
Once this shortcut is created, right-click on it, go to
Properties, click on the Change icon button and navigate to your icon file. Click on OK and you're done!
Your shortcut is now ready to be used. You can either copy it anywhere you want (i.e. on your desktop) or directly pin it to the taskbar (which is useful in Windows 7 as you then have a keyboard shortcut to use it).
That's it!! Now double-click on the shortcut or click on the taskbar icon to play that rimshot sound without having any media player opening.
Now have fun playing around with this, adding shortcuts to your desktop/taskbar to play anything from "Bazinga!" to "Fus-Ro-Dah!" whenever you feel like it.
Thanks for reading my first topic!
This could also be done with VBscript without installing NirCMD.
Set WshShell = createObject("Wscript.Shell")
WshShell.Run "C:\Sound.mp3", 0
This would run the sound file with the default media player for .mp3 files. The "0" somehow makes the program run invisibly. Then add another line to run the targeted program, without the "0" argument so it's visible. The downside to this is if the user is already using the default .mp3 program or if they intend to use it. I'm sure I could find a way to target a specific media player and close it after the sound plays.
This knowledge comes from a little prank I like to play, that I did some research on.
Set WshShell = createObject("Wscript.Shell")
WshShell.Run "C:\AnnoyingMusic.mp3", 0
The sleep line is the length of the sound file i want to loop in milliseconds, 268 seconds or 4:28 to be exact. I then schedule it to be run by the logged in user account in Task Scheduler for a few minutes later, after I make the task. The only downside to this is you can't keep the user from turning the volume to 0 in Windows or their speakers.
NirCmd doesn't need to be "installed", it's a stand-alone .EXE file that you can copy anywhere you want (if you have the permissions to do so). It's very quick to implement, even if you don't have administrative permissions on your computer (i.e. work laptop).
Thanks for the VBS knowledge though... and good job on the prank!!
It's always great to see what other people get to do for fun and what they learn doing it!
But for this "experiment", NirCmd was much easier to use and exactly what I needed.
And in your case, your media player problem and volume issue can both bite the dust if you use NirCmd...
Let me explain:
As I mentioned before, the mediaplay command plays a sound on the background without any media player showing up.
If you check the NirCmd documentation, you will see the following command.
setvolume [device] [left-volume] [right-volume]
Set the volume level of your sound device.
The [device] parameter represents the device identifier. In most cases, you should use '0' value for this parameter.
Under Windows Vista, you should specify 0 for default playback device or 1 for default recording device.
The [left-volume] and [right-volume] parameters should contain a value between 0 (silence) and 65535 (full volume) that represents the volume level for left and right channels.
So for your prank, create one scheduled task to run frequently (i.e. every minute) to set the volume high, and then run that annoying sound.
Try it and you will see how powerful this tiny component can be (either for fun or for a more serious purpose ).
You could probably combine this with AutoHotkey (or just the built-in shortcut keys in Windows) to create easy hotkeys to play funny sounds.
I'm going to stick this topic in our newsletter, maybe it'll help some other people tomorrow
I also have a handful of screenshots, but I couldn't add them to this post.
For the record, I also published this info here (with all the screenshots needed). I thought it might be easier to understand with visuals...
You should be able to add the screenshots here if you want as well.
Yes, now I can!
I've just edited it.
But I couldn't do it when I first wrote this as I didn't have the "Basic" badge...
I even added the links to the MP3 file and the ICO file...
I've never received a newsletter from HTG, so I didn'tt see if you added this topic to it.
How is that? Did I misconfigure my account preferences?
The email newsletter is actually a separate thing from the forum... there is a signup box at the bottom of the page on the main article site.
I actually realized that I can run it as an article on the home page. Going to look at doing that.
I've just subscribed to it! Thanks.
Looking forward to seeing that on the main page...
I added a pretty picture to the top of your post, and I added it to the home page of the site. It'll be featured in the newsletter tomorrow as well.
AWESOME!! Thanks a bunch!!!
Just dropping in to say, please make "From the Forum" a regular thing, I LOVE it!
I'm definitely planning on making it a regular thing, now that we've built the feature to easily take a forum topic and put it onto the main site / feed.
Haven't you guys done that before?
Not in the way that we're doing it now, it's running right alongside the regular posts, but the link is directly to the forum instead.
Glad to be the beta tester...
next page →