Danial Rosli
Danial Rosli

Reputation: 13

how to run a batch line from lua script

How to make it works. Im trying to run sound from batch through lua script


batch = [[
@echo off
set "file=wuuf.wav"
(echo Set Sound = CreateObject("WMPlayer.OCX.7"^)
  echo Sound.URL = "%file%"
  echo Sound.Controls.play
  echo do while Sound.currentmedia.duration = 0
  echo wscript.sleep 100
  echo loop
  echo wscript.sleep (int(Sound.currentmedia.duration^)+1^)*1000) >sound.vbs
start /min sound.vbs
]]

local p = io.popen([[cmd /c ]]..batch)

Upvotes: 1

Views: 694

Answers (1)

Egor Skriptunoff
Egor Skriptunoff

Reputation: 23767

local script = [[
   Set Sound = CreateObject("WMPlayer.OCX.7")
   Sound.URL = Wscript.Arguments(0)
   Sound.Controls.play
   do while Sound.currentmedia.duration = 0
      wscript.sleep 100
   loop
   wscript.sleep Sound.currentmedia.duration*1000+100
]]
local f = io.open("sound.vbs", "w")
f:write(script)
f:close()

local file = "wuuf.wav"
os.execute('wscript sound.vbs "'..file..'"')

Upvotes: 1

Related Questions