0
votes

I want to open .mp3 files with mpg123.exe silently when a .mp3 file is double clicked from within Windows Explorer. For this I wrote a VBScript as bellow and changed the default program for playing .mp3 files by assigning my VBScript to it via Open with → Choose default program. My script is working well from within command line (cmd.exe) but when a .mp3 file is double clicked I get an error message that double clicked .mp3 file is not an executable file in Windows. Here is my VBScript, please let me know where I am doing wrong.

if Wscript.arguments.count = 0 then
  WScript.quit
else
  strSoundFile = WScript.Arguments.Item(0)
end if

Set objShell = CreateObject("Wscript.Shell")

strCommand = "mpg123.exe -q " & chr(34) & strSoundFile & chr(34)

objShell.Run strCommand, 0, True 
1

1 Answers

1
votes

Why don't you just associate mp3 files with mpg123.exe and set up the associated parameters (eg: -q "%1") instead?

Since I couldn't find a notable existing example, I've whipped up an example for you. (tested to work on Windows 7 with mpg123.exe). The response was too image heavy to post here. I hope it helps you.