Ask a questionAsk a question
 

QuestionWscript.Shell open file in wmplayer (edited)

  • Saturday, October 31, 2009 10:48 PMcdubone Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I'm making an app in an hta that lives on a CD and opens wmv's from the CD. I thought everything was going well until I realized that if wmplayer isn't the default player the thing crashes. I have no idea why this is (I'm a Web dev and I'm totally out of my league here). Anyway, I'm trying to get around this by forcing wmplayer to open. Here's my code:

            Sub OpenFile (theFile)
                Set objShell = CreateObject("Wscript.Shell")

                LaunchDir = objShell.CurrentDirectory
                RelPath = "\assets\" & theFile
                ThePlayer = "wmplayer.exe "
               
                FullPath = chr(34) & ThePlayer & LaunchDir & RelPath & chr(34)
                document.write(FullPath)
                objShell.Run FullPath

    '            objShell.Run "assets\" & theFile
    '            objShell.Run "wmplayer.exe D:\assets\TheFile.wmv"
            End Sub

    The two commented lines: objShell.Run "assets\" & theFile and objShell.Run "wmplayer.exe D:\assets\TheFile.wmv" both work by themselves but neither is quite what I need. I need to have wmplayer open the file whose name is getting passed in as 'theFile'.

    The document.write outputs "wmplayer.exe D:\assets\TheFile.wmv" which seems right to me but I get the error: "The system cannot find the file specified" and "URL: file:///D:/index.hta"

    Anyone know what I need to do to get this working?

All Replies

  • Monday, November 09, 2009 12:24 AMcdubone Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I fogot to mention this was running from an HTA. Anyway, I got it going with this:

            Sub OpenWmv (theFile)
                Set objShell = CreateObject("Wscript.Shell")
                LaunchDir = objShell.CurrentDirectory
                RelPath = "\assets\" & theFile
                ThePlayer = "wmplayer.exe "
                FullPath = ThePlayer & chr(34) & LaunchDir & RelPath & chr(34)
                objShell.Run FullPath
            End Sub

    Cheers!