Skip to content

Instantly share code, notes, and snippets.

@hidsh
Created December 2, 2011 22:56
Show Gist options
  • Save hidsh/1425229 to your computer and use it in GitHub Desktop.
Save hidsh/1425229 to your computer and use it in GitHub Desktop.
media player classic で .iso を再生する wsh スクリプト
' play dvd iso
'
' 1. mount iso (using WinCDEmu)
' 2. launch mpc and play
' 3. unmount iso
'
MOUNTER="""C:\Program Files (x86)\WinCDEmu\batchmnt64.exe"""
DVD_DRV="v:"
PLAYER="C:\Users\g\Dropbox\apps\MPC-HomeCinema.1.5.2.3456.x64\mpc-hc64.exe"
'-----------------
' functions
'-----------------
Function is_mounted_any_iso_already(drv)
ret = False
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FolderExists(drv & "\\") Then ret = True
is_mounted_any_iso_already = ret
End Function
Sub mount(sh, iso)
sh.Run MOUNTER & " " & iso & " " & DVD_DRV,0, True
End Sub
Sub umount(sh)
sh.Run MOUNTER & " /unmount " & DVD_DRV,0,True
End Sub
Sub wait_for_activation(sh, app)
Do Until sh.AppActivate(app.ProcessID)
WScript.Sleep 500
Loop
End Sub
Sub wait_for_termination
Do
set proc=getobject("winmgmts:root\cimv2").execquery("select * from win32_process where name='wfica32.exe'")
wscript.sleep 500
Loop While proc.count = 1
End Sub
'-----------------
' main procedure
'-----------------
If WScript.Arguments.Count <> 1 Then WScript.Quit
If is_mounted_any_iso_already(DVD_DRV) Then WScript.Quit
Set ws = WScript.CreateObject("WScript.Shell")
mount ws, WScript.Arguments(0)
ws.Run PLAYER & " " & DVD_DRV & " /dvd /play",,True
wait_for_termination
umount ws
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment