![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| Vista Ultimate x64 | Wscript.Shell open file in wmplayer I'm making an app that lives on a CD that 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") objShell.Run "assets\" & theFile ' objShell.Run "wmplayer.exe D:assets\TheFile.wmv" End Sub This works: objShell.Run "assets\" & theFile And if I hard code a file reference it works: objShell.Run "wmplayer.exe D:assets\TheFile.wmv" I'm essentially trying to fuse those two lines of code - open 'theFile' in the assets directory via a relative path (not absolute) in wmplayer. I've tried so many ways to get this going but can't seem to find the one that works. Will someone show me how this is done? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Wscript.Shell open file in wmplayer "cdubone" <guest@newsgroup-email.com> wrote in message news:09b40379df88c25c91573f85a8d01528@newsgroup-gateway.com... Quote: > > I'm making an app that lives on a CD that 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") > objShell.Run "assets\" & theFile > ' objShell.Run "wmplayer.exe D:assets\TheFile.wmv" followed immediately by a "\". Similarly, the "D:" itself would not allow for this to work in a computer having two hard drives, or two CD drives. Quote: > End Sub > > This works: objShell.Run "assets\" & theFile > > And if I hard code a file reference it works: > objShell.Run "wmplayer.exe D:assets\TheFile.wmv" rather than relying on the path including the desired executable, and the "D:" drive containing the CD. Quote: > I'm essentially trying to fuse those two lines of code - open 'theFile' > in the assets directory via a relative path (not absolute) in wmplayer. > I've tried so many ways to get this going but can't seem to find the one > that works. > > Will someone show me how this is done? this will not modify the user's related settings on the workstation. Or you might do a search for wmplayer.exe on the hard drive, as it may not be located in the same place on all systems. /Al |
My System Specs![]() |
| | #3 (permalink) |
| Vista Ultimate x64 | Re: Wscript.Shell open file in wmplayer Yes, you're correct about about the slash in D:\assets\TheFile.wmv, that was just a typo. I can get the application to open wmplayer and a certain file if I hard code it. For example: objShell.Run "wmplayer.exe D:\assets\TheFile.wmv" works perfectly. However, if I construct that very same string it doesn't work: LaunchDir = objShell.CurrentDirectory RelPath = "assets\" & theFile ThePlayer = "wmplayer.exe " FullPath = chr(34) & ThePlayer & LaunchDir & RelPath & chr(34) document.write(FullPath) objShell.Run FullPath The document.write outputs "wmplayer.exe D:\assets\TheFile.wmv" which seems correct to me but I get the error "the system cannot file the file specified" "URL: file///D:/index.hta". Anyone know what I need to do to get this working? "cdubone" <guest@newsgroup-email.com> wrote in message news:09b40379df88c25c91573f85a8d01528@newsgroup-gateway.com... Quote: > > I'm making an app that lives on a CD that 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") > objShell.Run "assets\" & theFile > ' objShell.Run "wmplayer.exe D:assets\TheFile.wmv" followed immediately by a "\". Similarly, the "D:" itself would not allow for this to work in a computer having two hard drives, or two CD drives. Quote: > End Sub > > This works: objShell.Run "assets\" & theFile > > And if I hard code a file reference it works: > objShell.Run "wmplayer.exe D:assets\TheFile.wmv" rather than relying on the path including the desired executable, and the "D:" drive containing the CD. Quote: > I'm essentially trying to fuse those two lines of code - open 'theFile' > in the assets directory via a relative path (not absolute) in wmplayer. > I've tried so many ways to get this going but can't seem to find the one > that works. > > Will someone show me how this is done? this will not modify the user's related settings on the workstation. Or you might do a search for wmplayer.exe on the hard drive, as it may not be located in the same place on all systems. /Al |
My System Specs![]() |
| | #4 (permalink) |
| Vista Ultimate x64 | Re: Wscript.Shell open file in wmplayer 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 Thanks for the help! |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| WScript.Shell -> Terminal Server 2008... | VB Script | |||
| WScript.Shell echo command? | VB Script | |||
| Re: Have a command shell open but hidden | Vista General | |||
| Powershell starts but never exits when invoked from Wscript shell | PowerShell | |||
| WMPlayer open a song slowly after 5 sec with status "Media changin | Vista General | |||