0

I want to use the follwing powershell commands to automatically record a stream with vlc:

$rd = get-date -format "yyyyMMdd"
C:\"Program Files"\VideoLan\vlc\vlc.exe https://someurl/playlist.m3u --sout "#file{dst=C:\users\me\desktop\$rd.mp3}" --run-time=15 vlc://quit

That does work well if I save it as a .ps1 script and execute it with "Right Click > Run with PowerShell".

It also works if I paste those commands to the powershell and execute them in one line, like this:

$rd = get-date -format "yyyyMMdd"; C:\"Program Files"\VideoLan\vlc\vlc.exe https://someurl/playlist.m3u --sout "#file{dst=C:\users\me\desktop\$rd.mp3}" --run-time=15 vlc://quit

It even works if I execute this from within the Windows Terminal:

powershell -command {$rd = get-date -format "yyyyMMdd"; C:\"Program Files"\VideoLan\vlc\vlc.exe https://someurl/playlist.m3u --sout "#file{dst=C:\users\me\desktop\$rd.mp3}" --run-time=15 vlc://quit}

So I created a task in the Windows Task Scheduler to automate the execution.

This is the XML of the "Actions" tab:

<Actions Context="Author">
    <Exec>
      <Command>powershell</Command>
      <Arguments>-noexit -command {$rd = get-date -format "yyyyMMdd"; C:\"Program Files"\VideoLan\vlc\vlc.exe https://someurl/playlist.m3u --sout "#file{dst=C:\users\me\desktop\$rd.mp3}" --run-time=15 vlc://quit}</Arguments>
    </Exec>
</Actions>

Now, once the task is triggered, the opened PowerShell shows this error:

The string is missing the terminator: ".
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

What am I missing?

TylerH
  • 20,799
  • 66
  • 75
  • 101
  • 3
    Try changing out the braces `{ }` for double-quotes `" "` and escaping all the inside double-quotes with a backslash `\"` So I think the command should look like this `powershell -noprofile -command "$rd = get-date -format \"yyyyMMdd\"; & \"C:\Program Files\VideoLan\vlc\vlc.exe\" https://someurl/playlist.m3u --sout \"#file{dst=C:\users\me\desktop\$rd.mp3}\" --run-time=15 vlc://quit"` Have a look at this answer if you have 20 minutes to spare :) https://stackoverflow.com/a/31413730/11954025 – Daniel Jun 20 '22 at 23:32
  • 1
    Thank you! That worked: `powershell -command "$rd = get-date -format \"yyyyMMdd\"; C:\"\Program Files\"\VideoLan\vlc\vlc.exe https://someurl/playlist.m3u --sout \"#file{dst=C:\users\me\desktop\$rd.mp3}\" --run-time=15 vlc://quit"` – AbgrundLemur Jun 20 '22 at 23:48

0 Answers0