Scheduled Task for Windows
About
This is a alternative and easy way to run scheduled tasks on Windows. It is useful to workaround access or group policy restrictions, for example if your group policy logs you out after a short period.
The script has been tested to run as service using srvany.exe .
Features
- Can run scheduled programs every minute, hour, day or week
- Protocol events in a xml file
- Log all activities
Requirements
- srvany.exe
- Active State Perl >= 5.14
- Additional Modules:
- Win32::Process
- Win32::Process::List
Installation
Unextract and copy the files to a directory of you your choice, this example is using c:\scheduled-task
These are the required script files:
- c:\scheduled-task\st.pl
- c:\scheduled-task\st.xml
Perl Modules
You need to have a recent version of active state perl installed, please run the installation commands:
ppm install Win32-Process ppm install Win32-Process-list
Service Registration
Get the tool srvany.exe and copy it to c:\windows\system32\, then register the service by running:
sc create Perl-Scheduled-Task binPath= C:\Windows\System32\srvany.exe DisplayName= Perl-Scheduled-Task
Service Configuration
Open your registry and add the key Parmeters:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Perl-Scheduled-Task\Parameters]
- Add a string value called Application within Parameters and add the path to perl and the path to the script:
"Application"="c:\\perl\\bin\\perl.exe c:\\scheduled-task\\st.pl -c c:\\scheduled-task\\st.xml"
- Check your service permission, make sure the service user has enough permissions to start applications and has edit and create right in its application directory.
Script Configuration
Description of the configuration file used with st.pl.
Note: Please use forward slash as a directory separator like on linux even on wondows.
Element | Array | Attribute | Description |
---|---|---|---|
System | No | ApplicationDirectory | Path to appliactaion |
LogDirectory | Path to Log Directory | ||
StatusFile | Path to Status File | ||
ScheduledTask | Yes | Enabled | Job enable (1/0) |
Name | Any Jobname | ||
ApplicationPath | Path to perl, eg: c:/perl64/bin/perl.exe | ||
ApplicationParameter | Path to the script, eg: c:/scheduled-task/st.xml | ||
ApplicationPriority | Available: Below / Normal | ||
Mode | -- | ||
FrequencyUnit | -- | ||
FrequencyInterval | -- | ||
FrequencyOffset | -- | ||
IsUnique | -- |
|