in

andy vt's tools & blog

Flexibility isn't free

Replacing DVRMSFileWatcherService with batch and Task Scheduler

Last post 09-27-2007 12:46 PM by babgvant. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 09-26-2007 5:05 PM

    • are_bee
    • Top 200 Contributor
    • Joined on 03-11-2007
    • Pacific Northwest
    • Posts 8

    Replacing DVRMSFileWatcherService with batch and Task Scheduler

    Hi there Andy,

     I've been having problems with the DVRMSFileWatcherService spawning ComSkip.exe and then hanging. ComSkip.exe is showing Wait:Execute as it's status in SysInternals ProcessExplorer. To work around it I just built a batch file and created an associated Task Scheduler task to run it. The Vista Task Scheduler is pretty damn good! The task is kicked off when Media Center reports that it has successfully recorded a show - after a delay of 1 minute.

    Here's the batch listing. You need to save it somewhere as a .bat and modify the paths to match your system. The FORFILES line needs to end with \@fnamefileprocess.dvr-ms" "

    @REM
    @REM Set the paths to the appropriate directories. Note that they
    @REM need to be in short filename format (dir /x will show the short form).
    @REM

    @setlocal

    @set tvDir=C:\record~1
    @set commercialsDir=C:\Users\Public\DvrmsToolbox\CommercialsXml
    @set outputDir=C:\Users\Public\DvrmsToolbox\Output
    @set dvrmsToMpeg=C:\Progra~1\DVRMSToolbox\DVRMStoMPEG.exe

    @echo tvDir is %tvDir%
    @echo commercialsDir is %commercialsDir%
    @echo outputDir is %outputDir%
    @echo dvrmsToMpeg is %dvrmsToMpeg%

    @REM
    @REM Process commercials for all files in the Recorded TV directory
    @REM that don't have an associated commercial skip file in the public profile
    @REM
    forfiles /p "%tvDir%" /m *.dvr-ms /c "cmd /c if not exist "%commercialsDir%\@fname.xml" %dvrmsToMpeg% /if="@path" /of="%outputDir%\@fnamefileprocess.dvr-ms" "
    @REM This will delete commercial scan xml files for programs that have been deleted.
    forfiles /p "%commercialsDir%" /m *.xml /c "cmd /c if not exist "%tvDir%\@fname.dvr-ms" del @path"

    @endlocal

    Here is the definition of the task. You can save this as an XML file, edit it to match your system and the location of the batch file then import it through the GUI (Task Scheduler) or the command line tool SCHTASKS (from an elevated command prompt).

    <?xml version="1.0" encoding="UTF-16"?>
    <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
      <RegistrationInfo>
        <Date>2007-09-23T22:31:48.439442</Date>
        <Author>Hemingway\Richard</Author>
      </RegistrationInfo>
      <Triggers>
        <EventTrigger id="8d24094f-b360-4da5-958e-f73339d0960e">
          <ExecutionTimeLimit>PT2H</ExecutionTimeLimit>
          <Enabled>true</Enabled>
          <Subscription>&lt;QueryList&gt;&lt;Query Id="0" Path="Media Center"&gt;&lt;Select Path="Media Center"&gt;*[System[Provider[@Name='Recording'] and EventID=1]]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;</Subscription>
          <Delay>PT1M</Delay>
        </EventTrigger>
      </Triggers>
      <Principals>
        <Principal id="Author">
          <UserId>SYSTEM</UserId>
          <RunLevel>LeastPrivilege</RunLevel>
        </Principal>
      </Principals>
      <Settings>
        <IdleSettings>
          <Duration>PT10M</Duration>
          <WaitTimeout>PT1H</WaitTimeout>
          <StopOnIdleEnd>true</StopOnIdleEnd>
          <RestartOnIdle>false</RestartOnIdle>
        </IdleSettings>
        <MultipleInstancesPolicy>Queue</MultipleInstancesPolicy>
        <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
        <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
        <AllowHardTerminate>false</AllowHardTerminate>
        <StartWhenAvailable>false</StartWhenAvailable>
        <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
        <AllowStartOnDemand>true</AllowStartOnDemand>
        <Enabled>true</Enabled>
        <Hidden>false</Hidden>
        <RunOnlyIfIdle>false</RunOnlyIfIdle>
        <WakeToRun>false</WakeToRun>
        <ExecutionTimeLimit>P3D</ExecutionTimeLimit>
        <Priority>7</Priority>
      </Settings>
      <Actions Context="Author">
        <Exec>
          <Command>--edit this to point to the batch file--</Command>
          <WorkingDirectory>--anything you want here--</WorkingDirectory>
        </Exec>
      </Actions>
    </Task>

    Might be a bit low tech but it works.

    Cheers

    Richard

  • 09-27-2007 12:46 PM In reply to

    Re: Replacing DVRMSFileWatcherService with batch and Task Scheduler

    this is really cool... thx for sharing.

    was comskip getting executed before the recording was done? 

    DVRMSToolbox, Recording Broker, LcdWriter, and more software
    babgvant.com
Page 1 of 1 (2 items)
@2008 andy vt
Powered by Community Server (Non-Commercial Edition), by Telligent Systems