Vbs script were you can type the path of a mp3 to play it?

You can create a simple VBScript to play an MP3 file by using Windows Media Player through the command line. This is a straightforward approach, and here's an example script.

  1. Open a text editor like Notepad.
  2. Copy and paste the following code into the text editor:
' VBScript to play an MP3 file in Windows Media Player

Option Explicit

Dim strFilePath
Dim objShell

' Prompt user for the MP3 file path
strFilePath = InputBox("Enter the full path of the MP3 file to play:", "MP3 Player")

' Check if the file path is not empty
If strFilePath <> "" Then
    ' Create a shell object
    Set objShell = CreateObject("WScript.Shell")
    
    ' Command to run Windows Media Player with the selected file
    objShell.Run "wmplayer """ & strFilePath & """", 1, False
    
    ' Clean up
    Set objShell = Nothing
Else
    MsgBox "No file path entered.", vbInformation, "Information"
End If
  1. Save the file with a .vbs extension, for example, PlayMP3.vbs.

Instructions to run the script:

  1. Double-click the PlayMP3.vbs file to run it.
  2. A prompt will appear asking for the full path of the MP3 file you want to play.
  3. Enter the full path (e.g., C:\Users\YourUsername\Music\mysong.mp3) and click OK.
  4. Windows Media Player should open and start playing the specified MP3 file.

Note:

Make sure that Windows Media Player is installed on your system, and that the file path is correct. The MP3 file should exist at the specified location, otherwise, the script won’t work as intended.

Have your own question?

Ask the AI now