Reputation: 236
I have a VBS script that plays a sound file at whichever directory is passed to it. Here is the script:
Dim oPlayer
Set oPlayer = CreateObject("WMPlayer.OCX")
oPlayer.URL = WScript.Arguments.Item(0)
oPlayer.controls.play
While oPlayer.playState <> 1 ' 1 = Stopped
WScript.Sleep 100
Wend
oPlayer.close
This is the C# script i use to call the VBS:
System.Diagnostics.Process.Start(@"myscript.vbs", "mydir\0.mp3");
I also tried:
System.Diagnostics.Process.Start(@"myscript.vbs", @"mydir\0.mp3");
The script cannot play/find the sound file. I get the error "Cannot play file with unknown extension". However, it works perfectly fine when I call the VBS with a batch file:
cscript myscript.vbs mydir\0.mp3
Any ideas? Thanks!
Upvotes: 1
Views: 56
Reputation: 236
After messing around for a while, I have identified the problem: the VBS script wasn't executed from the directory I wanted it to. The fix was simple: instead of using a relative directory, I passed it the full path:
C:\something\mydir\0.mp3
Upvotes: 1