Jump to content

Ramping up the volume with VBScript


Recommended Posts

After re-watching one of the episodes where a viewer asks if there is a way to make his computer's volume gradually increase to provide a gentler wakeup, I thought I'd have a go at finding my own way to do it with VBScript and a few other files.

The first thing you need is the 2003 Resource kit from Microsoft. You can get it here:


And the second this, is NirCmd. NirCmd is a really handy little exe with a ton of options for controlling windows. It's very useful for giving scripts a little bit of extra power, and it's well worth having anyway. You can get it here:


First things first, of course... Download and install the 2003 resource kit tools. You need this for a little program called "sleep". Basically, it does nothing but wait for a specified amount of time, and then terminates.

Then download NirCmd. NirCmd comes as 3 files in a zip file. You need to put the nircmd.exe file somewhere in your PATH. I've put it in my windows folder, but you can put it wherever you would like, as long as it's in your PATH. If you don't: you will have to edit the VBScript accordingly.

Next comes the VBScript. Basically, what it does is to set your volume to zero using NirCmd, start your chosen music player (WinAmp in my case) using your chosen playlist, and then proceeds to up the volume in increments until the desired volume is reached.

The VBScript looks like this:

Set WshShell = WScript.CreateObject("WScript.Shell")    'Make a shell object to use

MaxVol = 30000    'Set the volume to ramp to, a value between 0 and 65535

WaitTime = 10    'Set the delay between each step up in volume (in milliseconds)

Increment = 100    'Set the amount the volume steps up by each time

PlayerPath = """c:program filesWinAmpWinAmp.exe"""    'Set the full path to your music player

PlaylistPath = """c:playlistsbeatles.m3u"""    'Set the full path to the playlist you want to use

CurVol = 0    'Make sure the volume is at 0 to start with

WshShell.Run "nircmd setsysvolume " & CurVol ,0,1

WshShell.Run PlayerPath & " " & PlaylistPath    'Start the music player with the playlist

Do While CurVol < MaxVol    'Ramp up the volume using the previously set parameters

    WshShell.Run "nircmd setsysvolume " & CurVol ,0,1

    WshShell.Run "sleep -m " & WaitTime ,0,1

    CurVol = CurVol + Increment


'And we're done!

Save the above as a .vbs file in somewhere meaningful (c:alarmalarm.vbs perhaps), and that's pretty much it!

You can play about with MaxVol, WaitTime and Increment to get the volume ramping to behave how you want.

You can use the Windows 'at' command to schedule the script to run as an alarm in the morning, just as described in the Hak5 RSS alarm clock tutorial. Like so:

at 07:00 /every:m,t,w,th,f c:alarmalarm.vbs

Remember to change PlayerPath and PlaylistPath to suit your system. The triple quotes are needed because VBScript isn't best friends with filenames that include spaces :P

One last thing... You may have to edit the line that executes your music player if you are using a player other than WinAmp. Not all players will let you pass a playlist file to them as an argument, but WinAmp is fine with it :)

Have fun! And if you have any suggestions, or any problems, be sure to let me know.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...