Southsoftware.com
   

Advanced Task Scheduler under Wine

Since version 7 Advanced Task Scheduler is adapted to run under Wine on Linux and MacOS. Older versions could not run under Wine properly as Wine does not implement Windows Ribbon Control and Windows Terminal Services.

Without Windows Ribbon Control the old-fashioned menu bar is displayed.

As Wine does not implement Windows Terminal Services, some user-related features will not work. For example, "Start this task only if one of the following users is logged and active" and "Start this task for each logged on and valid user (even those who are logged on but not active at the time)" options. These options are explained in the post about terminal services.

Therefore, under Wine, there is no actual difference between tasks on the current user's tab and "All Users" tab except that the tasks on the "All Users" tab are operated by the service and run in the background as long as the service and the wine server are running.

Another limitation is that the "Save Stdout to log" option in the "Launch application" task does not work for native programs in Wine. Therefore, tasks from the "Script" section can't run with native interpreters as they rely on that option. But they can run with interpreters that run under Wine as well.

However, it is possible to run a native program or script from the "Launch application" task. The Perl script below can be used to convert Wine-relared paths to native paths when running a native program: unixcaller.pl

#!/usr/bin/perl

# This script spawns a child process with the given command line argiments.
# The arguments are processed in the following way:
#  1. Environment variables in the form of $VARIABLE are expanded;
#  2. The ~/ shorthand will be replaced by current user's home directory;
#  3. If argument contains ` (backticks) it will be evaluated (executed).
# Examples:
#  unixcaller.pl ls ~/
#  unixcaller.pl echo "$USERNAME"
#  unixcaller.pl vlc "`wine winepath -u \"c:\Name with spaces.avi\"`"

use strict;
use warnings;

my @args = ();

foreach (@ARGV) {
  # $ENV
  $_ =~ s{\$(\w+)}{ exists $ENV{$1} ? $ENV{$1} : '$'.$1 }ge;
  # ~/path
  $_ =~ s{~\/}{ exists $ENV{HOME} ? $ENV{HOME}.'/' : '~/' }ge;
  # `cmd`
  $_ =~ s{`([^`]*)`}{
    my @output = qx($1);
    chomp(@output);
    join(' ', @output);
  }ge;

  push @args, $_;
}

system(@args);

Do not forget to cast chmod +x unixcaller.pl. The following example of a "Launch application" task demonstrates how to pass a Wine-related path to a native program:
Executable file name: c:\unixcaller.pl
Command line arguments: vlc "`wine winepath -u \"c:\Name with spaces.avi\"`"

References
Terminal Server Aware Task Scheduler
Launch application

Categories: Task scheduler

Leave a Reply

   
About us   Cookie policy   Privacy policy   Terms of use   Link to us