Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Double-clicked file as input parameter to vbscript

$
0
0

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 when executed from command line (cmd.exe) but when a .mp3 file is double clicked in windows explorer 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

Thanks David


David De


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>