Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Mar 2003
    Location
    Elkins Park, Pennsylvania, USA
    Posts
    325
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Launching WMP from a VBS file (VBScript)

    Hi. I hope this is short, and that I won't come across as TOO stupid...

    I have a script that I want to launch Windows Media Player. I thought the code should be something simple like this:

    dim wsh
    set wsh = WScript.CreateObject("WScript.Shell")
    wsh.Run "C:Program FilesWindows Media Playerwmplayer.exe", 1
    set wsh = nothing

    However, when I run it, I get an error saying that the file could not be found. (The path is indeed correct.) Being fairly new at VBScript, I thought maybe I screwed up the syntax. However, when I use a "command line" that doesn't include spaces, e.g. wsh.Run "C:MyTest.bat", 1, everything works just fine.

    Is it something about the spaces? Is there a better way to do it? (I want to use a script because there are certain environment things I want to check before launching it.)
    <font face="Comic Sans MS">That's what you do in a herd; you look out for each other!</font face=comic> - Mike

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Launching WMP from a VBS file (VBScript)

    Yes, it's the spaces - use this:
    <code> wsh.Run """C:Program FilesWindows Media Playerwmplayer.exe""", 1</code>
    HTH
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    3 Star Lounger
    Join Date
    Mar 2003
    Location
    Elkins Park, Pennsylvania, USA
    Posts
    325
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Launching WMP from a VBS file (VBScript)

    Thank you so much for the quick reply. It worked like a charm.
    <font face="Comic Sans MS">That's what you do in a herd; you look out for each other!</font face=comic> - Mike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •