NnCron is an improved task scheduler for Windows. Last words of advice for action

Hi all. Today I will tell you about the wonderful program nnCron.

Meet nnCron, a cron scheduler and task manager from UNIX rewritten for Windows.
An incredibly convenient and useful program will help you deal with tasks that require regular execution and remind you of important matters.

Download and install nnCron

At the end of the article you will find a “nncron download” link. After the download is complete, run the file “nncron_rus.exe”. Installation is not difficult. nnCron works on all Windows, there is even nncron for Windows 7. By the way, on Windows 7 there is one trick. In order for nnCron to work normally in Windows 7, during installation you need to select the “install for the current user” and “install for all users” options, and check the “install as remove the service” checkbox. In order for the program to work in Russian, after installation, right-click on the tray icon and select Options->Language, then select Russian from the list, click OK. nnCron will prompt you to save the configuration and restart it, agree and now it is in Russian.

Register nnCron

Now about the issue of nnCron registration that interests many. The program is paid, but don’t rush to look for a crack for nnCron, there is good news - for all residents of the former USSR nnCron is free for non-commercial use. Therefore, forget about cracks, select “Register nnCron” in the program menu. In the window that appears, enter “xUSSR registration” in the “Registration name” field and the current day of the week in Russian letters, for example, “Thursday” in the “Registration code” field. Click OK. Congratulations! You have just registered nnCron and now you can use it for your pleasure.

This mysterious Mr. Fort

Let’s continue our presentation with the last assumption I voiced, “what if you suddenly are a programmer.” Since the power of nnCron truly becomes apparent only when you master this programming language, it makes sense to dwell on it very briefly. The trick is that any program design of a program can be “advanced” in any way due to the built-in ability to interpret commands of the Forth language. It turns out that you get not just a finished tool, but only a powerful blank that you can modify in accordance with your requests (okay, the alternative is the requests of your employer).

So, Forth (or rather, its domestic dialect) is a programming language in which programs are written in postfix notation and in stack notation, while it supports meta-extension mechanisms for changing the semantics and syntax of the language when customized to a specific subject area. The base-level syntax in Forth is simple and consists of a single rule: “All definitions are separated by spaces.”

Forth definitions can have any combination of characters, allowing you to essentially build your own new language on top of the previous language(s). It is from this puff pastry that the scripting language-framework for nnCron is molded, leaving you the opportunity to build your own on its solid foundation.” the perfect machine to automate anything"(or be content with everything available). That is why I waited almost until the end of the article with a list of the general features of the program, because they... they are endless!

And the simplest option for such an extension in nnCron is plugins. These are ordinary text files with the .spf extension, designed as additional nnCron modules, also written in the Forth language, which expand the functionality of the program by adding their own new words (operators and instructions). The nnCron distribution includes more than a dozen useful (and not so useful) plugins, which are located in the plugins subdirectory of the nnCron home directory.

In conclusion, for all novice metaprogrammers fascinated by the magic of the Forth language, I will kindly provide a ready-made answer to your first unspoken question: how can I display a list of all Forth words located in the dictionary (read - womb) of nnCron? There is nothing simpler: open the Forth console (for more traditional programmers, I’ll explain that this is a kind of standard door into the inside of the program, with which you thus have the honor of communicating, and this is possible both locally and remotely - over the network) and enter the command there WORDS. Yes, I almost forgot to warn you: get ready to see a list of about three thousand words.

For everyone who wants to learn how to expand nnCron: on the one hand, I propose to start your excursion into the rich world of the Fort language with this informative one, and on the other hand, I confidentially inform you that you can download the source code of the nnCron program itself (and to top it off, the traditional bad news is that this is far from its most recent version). Remember, Forth is a very concise language that requires deep preliminary thought and transcendental meditation on the code, uncontaminated by our vain post-industrial existence.

To explain this idea, I’ll simply quote the first line from the book “ Pioneers of programming"famous, who begins chapter No. 4 about the Fort language with this sentence:

“Every time I hear someone brag about the millions of lines of code they have written, I am sure that person has grossly misunderstood their task.”

A hybrid of planner, automation and scripter...

After going for a long time from the specific to the general, we finally came to a list of the main areas that nnCron effectively solves, and this is what it is capable of:

    • run arbitrary programs (as well as yourself) as system services;
    • run tasks “on behalf of” specified users;
    • track and restart overdue tasks and reminders;
    • turn off or “put to sleep” the computer at a given time, “wake up” the computer to start a task;
    • display/hide/close/kill/minimize/maximize and hide specified windows in the system tray, add arbitrary icons and programs to the system tray;
    • change the size and location of windows, as well as change their “transparency”;
    • display any messages on the screen and in a log file, including requests to perform specified actions;
    • work with clipboard, files and registry;
    • emulate keyboard input and mouse operations;
    • call via modem and hang up;
    • play audio files and “beep” through the system speaker;
    • synchronize system time;
    • assign the specified priority to processes and interrupt the operation of any running processes;
    • automatically restart after fatal errors;
    • script everything else, unlimitedly expanding the functionality of the program, in the built-in language, the Forth metalanguage, VBScript/Jscript, and all this with support for regular expressions;
    • nnCron is capable of tracking files, flags, windows, processes, mouse movements, computer idle time, keyboard shortcuts, online/offline access, the appearance of a disk in the drive, the presence of a host on the network (ping), changing a remote resource via the http protocol, the amount of free disk space, RAM load and much, much more - after which somehow automatically handle all these situations;
    • For those who need a “less sophisticated” and at the same time “lighter” version of the program, a “light” version of it has been specially compiled, which is carefully optimized and stripped of excesses, where only the most essential and small-sized ones are left.

Last words of advice for action

This program has three significant disadvantages. Firstly, the abundance of its beneficial properties is such that in order to use them effectively, you must first study a little, sit down and figure it out properly (I hope this article will help at least a little with this). In addition to the wonderful documentation, I recommend starting to study the program with a very accessible and simple step-by-step guide, after which it is advisable to preview the program.

Secondly, perhaps the most unpleasant and sad point is that the development of the program has been abandoned since 2009. Partly, the margin of safety (within the framework of its functionality), given to it in the latest existing version 1.93, allows it to feel great to this day in a mode of life completely autonomous from the developers, but, like any abandoned thing, the program is still beginning to become obsolete. And the main current problem in this regard is poor compatibility with Windows 7, for which it was never tested or intended. However, a number of volunteers have already assembled their own unofficial and “tailored builds” for Win7.

Therefore, owners of the latest Windows can first try “special” assemblies: you can take this one from or another alternative from (). Both of these builds have their pros and cons, so I encourage you to test them out and choose your favorite for yourself.I recommend that all other OS users use nnSoft.

Thirdly, you need to keep in mind that nnCron is destined to work in close conjunction with a related utility from the same manufacturer - nnBackup. In short, it is extremely successful and has a device system that is largely similar to nnCron (I wrote about it earlier). At the same time, it’s even difficult to single out the intended purpose of these two utilities: they equally well take root both on a personal computer and on servers running server versions of Windows (the available “as a service” operating mode is especially suitable for the latter option).

And last but not least, I’ll give you an important detail: nnCron free for citizens of countries of the former USSR (subject to non-commercial and non-corporate use). Detailed information about the free registration procedure is available.

NnCron is a compact (less than 1MB in size) and powerful task scheduler for Windows, distributed free of charge for private, non-commercial use. Compared to most schedulers, including the built-in Windows MSTask.exe, nnCron allows you not only to run tasks at a given time, but also to respond to certain events, such as file modification, creation, change or deactivation of a window, startup or termination process, establishing or breaking an Internet connection, etc.

Main features of nnCron:

  • can be run as a service or as a regular application
  • understands the cron format (Unix) and is controlled using cron.tab text files, the format of which is compatible with the crontab file format of Unix systems
  • can track and restart overdue tasks
  • knows how to set and use environment variables
  • can run processes on behalf of the currently authorized user (WinNT/2000/XP)
  • allows you to run plugins (scripts of arbitrary complexity) written in the Fort programming language
  • Flexibly customized to meet specific user needs
  • not demanding on computer resources.

Installing nnCron is done in the usual way. After the installation is completed and the nnCron service is started, the scheduler icon will appear in the system tray. Right-clicking on the icon allows you to access the main program menu.
To register nnCron, go to its home directory (usually C:\Program Files\NNCRON\) and run tm.exe with the xReg parameter.

tm.exe xReg

In the window that appears, enter xUSSR registration as a name and current day of the week(in Russian) instead of a password.

The main program settings are stored in the nncron.ini file in the program's home directory. To change settings, it is convenient to use the main menu, called up with the right mouse button. Select "Settings"

The program settings are intuitive and quite sufficient for comfortable work with the scheduler. If necessary, you can change the program language, select the format and placement of log files, crontab backups, help system, task launch modes, their priority, menu items and some other options.

In addition to settings, through the main menu of the program you can call up help, additional tools that make it easier to create tasks, edit or force a specific task, create a new task or reminder, and view the current nncron log file.

Create reminders and tasks.

Data about tasks and reminders created for the scheduler are, by default, saved in a file nncron.tab scheduler directory (.\Program Files\nnCron). Task records can be presented in classic mode or expanded.

Classic mode corresponds to the crontab file format of Unix systems and is a line containing the time in cron format and a command separated by a space. Empty lines and lines starting with a character # , are not processed (except for the design #() .

# Minutes Hours Days Months WeekDays Command
*/15 8-16 * * 1-5 checkmail.exe

The first line is a comment, the second consists of five fields separated by spaces:


and the name of the program being launched - checkmail.exe.

Symbol * defines "all" instead of value. Those. * in the field means that the task must be executed on all days of the month. A specific value can be specified as a decimal number or a range of numbers. So, in the line in question, the field indicates 8-16 - this means that the task will be executed from 8 o'clock to 16. It is possible to specify values ​​separated by a comma - 8,9,10,11,12,13,14,15,16. In the field, the entry looks like this - */15. This means "step" - every 15 minutes. Entry 1-5 in the field means "Monday to Friday".
As a result, the line will mean "Run the checkmail.exe task every 15 minutes of every hour of every day of every month on weekdays."

A lightweight version of nnCron called nnCron Lite, differs from the professional one in that it does not have a graphical user interface, and the scheduler can only process tasks in classic mode. The tasks themselves are created by manually adding entries to the nncron.tab file. Advanced Mode - the main and most powerful syntactic mode of operation of nnCron. In advanced mode, the user has the opportunity to create named tasks (Tasks), each of which is launched at a time specified by the user and allows you to fine-tune the actions themselves and the conditions under which they are performed.
The description of each task begins with the following syntactic structure:

#(task_name

Having encountered this sequence in the nncron.tab file, the scheduler switches to the advanced mode of processing the task record until the sequence is detected

)#

Signifying the end of the recording.

When it encounters a sign of the end of a task record, the scheduler switches back to classic mode. This was done so that records in any format could be located anywhere in the same nncron.tab file (crontab).

Job entries in nncron.tab can be created either using the nnCron graphical shell or by editing its contents using a regular text editor.

Classic format entries are not displayed in the task list when opened using the GUI. They are not named and are created, modified and deleted manually when editing the nncron.tab file

To add a task or reminder in the graphical shell, use the main menu, which opens by right-clicking on the nnCron icon in the desktop notification area (system tray).

On the first tab ("Time") you need to specify the name of the task, the start time or event on which the launch will occur, and the account with whose rights the task will be executed. If the user is not specified, the task will be executed with the rights of the System Local Account. Please note that some launched applications can only be successfully executed under a specific account and require loading a user profile (MS Office applications, for example).

On the "Action" tab, you need to determine what exactly the created task should perform. The selected action option will cause the display of additional options, the indication of which is necessary for the successful completion of the task.

The "Advanced" tab will display the created task as it will be written to the nncron.tab file. For example:

AsLoggedUser - as the logged in user
Time: 30 9 * * 1-5 * - time in crown format
Action: - selected action and its additional options (below)
StartIn: "C:\SCRIPTS\TEST" - working directory
ShowNormal NormalPriority - the priority with which the task will be executed
START-APP: C:\SCRIPTS\TEST\test1.bat- the action will be used to launch the command file test1.bat

Practical examples of problems.

Restoring an Internet connection when it is broken.

Let's call the task "Reconnect". The connection used to connect to the Internet is usually created for each individual Windows user. In the example, the task will be executed on behalf of the logged in user. Instead of time, choose a condition By event and from the list of events available for processing by the scheduler - When the Internet connection is lost

Now you need to select a tab Action and, from the list of available actions - Establish an Internet connection
Then, you need to select the required connection, specify the username and password associated with it, and also set the number of attempts and the interval in seconds between them.

After saving the task, if the Internet connection is lost, the scheduler will restore it, if technically possible.
One of the existing remote access connections in the system (dialup, VPN, PPPoE, etc.) can be selected as an Internet connection. The task created in this way will be added to the nncron.tab file in the form:

#(Reconnect
WatchDisconnect
Action:
RASUser: "stm234567"
RASSecPassword: "Qrt3rkJ="
DIAL: "Stream" 10 15
)#

The same task can be created without using a graphical shell by simply copying the above text into the nncron.tab file. After which, the task will appear in the list of scheduler tasks and will become available for editing in the right-click context menu, in the “Edit” item. For it to work, you must enter the correct password for the connection being restored, since, for security reasons, the scheduler stores it in its internal format, and not in clear text. You can also get the password saved by nnCron using the command

Nncron.exe -ep PASSWORD

In response to such a command, a window will be displayed with the text of the stored password corresponding to the word "PASSWORD"

Using the "File Creation/Changes" event.

The ability to launch tasks based on the “File creation/changes” event is a very useful scheduler feature that allows you to solve problems such as the execution of a complex task by several computers, taking into account intermediate results.

You can select modification of a file on a network drive as the event that triggers the task. And, if you create tasks on several computers that monitor the creation or modification of the same file on a network drive, then when an event occurs, task execution will begin on the entire group of computers. In addition, you can organize the execution of a task using a special command file that analyzes the contents of a modified (monitored by the scheduler) file, and, depending on its content, execute one or another task. As an example, I used a similar technique to automatically replace certain files in certain directories on several computers when the source (file version) is unknown in advance.

To analyze the contents of a modified file, you can use the following construction

REM FOR /F "parameters" - use data from file
REM Variable %%I - word from file

FOR /F %%I in (Q:\PUBLIC\DIR\startfile.txt) do (
xcopy /Y /S "X:\SourceDir\%%I\*.*" c:\DestDir\*.*
IF %ERRORLEVEL% NEQ 0 net.exe send ADMCOMP XCOPY Error = %ERRORLEVEL% .
R.E.M.
...

This example modifies the contents of the file Q:\PUBLIC\DIR\startfile.txt. It contains the name of the subdirectory located on the network resource X:\SourceDir\ . The xcopy command is used to copy its contents to the local C: drive in the DestDir directory. The process of starting a task can be initiated by executing the command

Echo datadir > Q:\PUBLIC\DIR\startfile.txt

After its execution, a text string will be written in the file Q:\PUBLIC\DIR\startfile.txt with the name of the subdirectory from which the source files to be copied should be taken.

    To run selected programs on a schedule, it is very convenient to use the nnCron task scheduler (Author - Nikolay Nemtsev). With its help, you can launch any processes at a specified time and with a specified frequency. nnCron LITE is distributed free of charge, is accompanied by very clear documentation in Russian and works with all Windows operating systems. nnCron (not LITE) for non-commercial use is also free for citizens of the former USSR, but requires registration. It incorporates all the best from the world-famous UNIX cron scheduler. You can download the latest version of nnCron LITE (230kb) and nnCron from here: www.nncron.ru
    Main features of nnCron:
-- can be launched as a service or as a regular application
-- understands the cron format (Unix) and is controlled using cron.tab text files, the format of which is compatible with the crontab file format of Unix systems
-- can track and restart overdue tasks
-- can set and use environment variables
-- can run processes on behalf of the currently authorized user (WinNT/2000/XP)
-- allows you to run plugins (scripts of arbitrary complexity) written in the Fort programming language
-- flexibly customized to meet specific user needs
-- not demanding on computer resources.

    nnCron LITE is much easier to use than nnCron, but also more modest in capabilities. For example, consider using nnCron LITE to solve the following problem:

    On the local network, it is necessary at 17.00 every day, except weekends, to transfer the archive of the directory C:\BASE from computer PC1 to the directory D:\ARHIV on computer PC3, and at 22.00 daily turn off computer PC3 and turn it on at 8.00. and at 8.30 run the program.exe program on it.

    A simple solution suggests itself using nncron on each machine, but we will complicate the situation by considering PC2 as an administrator's computer with nncron installed, and PC1 and PC3 as ordinary user computers. Those. PC2 will manage all processes. This imposes some restrictions on its configuration - the OS on it must be Win2k/XP with administrator rights in relation to the resources of other computers.
    To solve this problem, we need not only nncron, but also some of the utilities of the Pstools package.


Step one - install and configure nncron on PC2.

    First, download nnCron LITE. Today, the nncron Lite version is available on the website www.nncron.ru in the form of the executable module nncronlt116.exe. We launch it, select the language (it is better, of course, to choose Russian), the installation option (for one user or for everyone on a given computer) and the directory where the program will be located. After the installation is successfully completed, you will see a summary window informing you that the installation is complete and the nnCron LITE service has started. The nnCron LITE section has appeared in the Programs menu, allowing you to start or stop the service.
    In general, everything is ready to work, but it would be advisable to install nncron as a system service so that it starts automatically regardless of the user logging into the system. To do this, go to the folder C:|\Program Files\cron and launch install_svc.bat. There is a text file in the same folder cron.tab, the contents of which are the main tool for managing the launch of jobs. After installation it contains the following:

#CRONTAB FILE
# Classic crontab format:
# Minutes Hours Days Months WeekDays Command
#*/15 8-16 * * 1-5 checkmail.exe

    Lines starting with character # are comments and are not processed by the scheduler (as are empty lines). Those. this file contains nothing but comments giving a brief description of the classic crontab format (there is also an extended format) and an example for running checkmail.exe.
The last line (cron format) consists of five fields separated by spaces:

and the name of the program being launched - checkmail.exe.

    Symbol * defines "all" instead of value. Those. * in the field means that the task must be executed on all days of the month. A specific value can be specified as a decimal number or a range of numbers. So, in the line in question, the field indicates 8-16 - this means that the task will be executed from 8 o'clock to 16. It is possible to specify values ​​separated by a comma - 8,9,10,11,12,13,14,15,16. In the field, the entry looks like this - */15. This means "step" - every 15 minutes. Entry 1-5 in the field means "Monday to Friday".
As a result, the line will mean "Run the checkmail.exe task every 15 minutes of every hour of every day of every month on weekdays."

    To check, let's create a simple task:

"Run the Windows command interpreter every 2 minutes."

The cron.tab line should be like this:

*/2                      *                 *                 *    nbsp          *                       cmd.exe

Add the line to cron.tab:

*/2 * * * * cmd.exe

And we make sure that the task is completed. If this is not the case, look at the contents of the folder /log, where nncron keeps a log of its actions. The reason is usually that the task name is incorrect or is not present in the search paths specified by the PATH environment variable. If you use the crontab format line above on Win9x/Me, you will get an error because the command interpreter on those OSes is command.com, not cmd.exe, and the line would look like this:

*/2 * * * * command.com


Step two - create jobs for nncron.

    Having made sure that nncron is working, we delete our test line and begin generating lines to complete our task.
To begin with, we need to transfer the archive of the directory C:\BASE from computer PC1 to the directory D:\ARHIV to computer PC3 at 17.00 every day, except weekends. There are no problems with creating the conditions for starting a task, but what task should I start? There may be several solutions, but let's consider the simplest one - nncron will launch not an executable module, but a bat file in which the network drives of computers PC1 and PC3 will be connected and archived using an archiver launched from the command line. Let this file be called arh.bat and is located in the directory C:\SCRIPTS our computer PC2.

      0                 17                 *                 *               1-5                 c:\scripts\arh.bat

Content arh.bat could be as follows (lines starting with "rem" in batch files are comments):

rem Connect drive C of computer PC1 as network drive M:
net use M:\\PC1\C
rem Connect drive D of computer PC3 as network drive N:
net use N:\\PC3\D
rem Archive C:\BASE of computer PC1 to D:\ARHIV of computer PC3 using the archiver arj
arj a N:\ARHIV\PC3base.arj M:\BASE\*.*
rem remove network connections
net use N: /delete
net use M: /d

    Launch arh.bat and make sure it works. Then add the line to cron.tab:

0 17 * * 1-5 C:\scripts\arh.bat

    The first part of the task is completed. The second (turn off the PC3 computer at 10 p.m. every day and turn it on at 8 a.m. and run the program.exe program on it at 8.30 a.m.) will require command line utilities that allow you to perform remote administration. To do this, we will use the utilities from the PsTools package from Sysinternals and broadc.exe. Just in case, I have posted here links to the utilities that I use myself:

Psshutdown- shutdown/restart utility (download, 126kb)
Allows you to shut down or restart both local and remote computers. Command line format:

psshutdown -s|-r|-h|-d|-k|-a|-l|-o [-f] [-t nn] [-m "Message "] [-u Username [-p Password]] [\\computer]
    Examples of use:
psshutdown -k \\PC3- turn off PC3. Instead of the computer name, you can specify its IP address. If nothing is specified, then the local computer is meant.
psshutdown -r\\192.168.0.1- reboot the remote computer with IP address 192.168.0.1.
Psexec- a utility for launching tasks on a remote computer from the PSTools Microsoft package (Sysinternals). (download PSTools.zip)
Command line format:

psexec \\computer][-u user [-p psswd]][-s|-e][-i][-c [-f|-v]][-d][- ][-a n,n, ...>]cmd

psexec\\PC3 program.exe- execute program.exe on the remote computer. The program being executed must be in the search paths.
psexec \\PC3 -c C:\SCRIPTS\program.exe The executable program is copied to the remote computer from C:\SCRIPTS and executed.
Broadc- a utility for turning on a computer via a local network. (download, 32kb)
Command line format:

broadc.exe MAC address of the network card 255.255.255.255 67
    Examples of use:
bbroadc.exe 0002b3d8b4e6 255.255.255.255 67- turn on the computer whose network card MAC address is 0002b3d8b4e6. The motherboard and network card must support remote power-on and the BIOS must support advanced power management.

Create a task schedule:

      0                 22                 *                 *               *                 psshutdown
      0                 8                   *                 * nbsp               *                 broadc
      30               8                   *                 *               *                 psexec

You can skip the lyrics and go to the separately marked part of the post below.

It may be objected to me that windows7, for example, has a good own scheduler with rich capabilities. But I don't like him. I suspect that resources are being wasted, the convenience of creating new tasks... is not for everyone. Etc. In addition, many things are not possible in principle (without sufficiently highly qualified intervention) ...

Tomorrow we will set up the converter and you can use it...

For example, my (temporary, quick-fix) code looks like this:

#(vdasus.4pic NoLog ;" do not log SingleInstance ;" While the task is running, run it again - it is necessary that it does not trigger when the thumbnail appears WatchDir: "D:\4Pics\" ;" Watch the directory Action: RECURSIVE FILESONLY SKIPERRORS ; " If the task has started, find all the appeared files FOR-FILES: "D:\4Pics\*" RE-MATCH: "%FOUND-FILENAME%" "/\b(th_)?!\w+\.((gif)| (jpeg)|(jpg)|(png)|(ico)|(bmp))/i" ;" If there are files - pictures IF ShowMinimized NormalPriority QSTART-APPW: "C:\Program Files\_APP\vdush2\vdushc2. exe" %FOUND-FULLPATH% ;" Run the converter program for each WIN-ACTIVATE: "Semagic" ;" Activate the Semagic application SEND-KEYS: "^v(ENTER)" ;" Send there Ctrl+V (Edit \ Paste) ShowNormal NormalPriority ;" Upload via ftp to hosting START-APPW: winscp.exe /console /command "open ftp://zzzz@zzz: [email protected]" "option transfer binary" "put %FOUND-FULLPATH%" "exit" THEN ;FOR-FILES RECURSIVE FILESONLY SKIPERRORS FOR-FILES: "D:\4Pics\*" RE-MATCH: "%FOUND-FILENAME%" "/ th_\w+\.((gif)|(jpeg)|(jpg)|(png)|(ico)|(bmp))/i" ;" Find the files that appear thumbnail IF ShowNormal NormalPriority ;" Upload via ftp to hosting START-APPW: winscp.exe /console /command "open ftp://zzzz@zzz: [email protected]" "option transfer binary" "put %FOUND-FULLPATH%" "exit" THEN ;FOR-FILES)#

Don't be alarmed - you won't have to write it yourself :) You just need to tweak a couple of parameters...

Tomorrow the rest :) Just try it - it's not as difficult as it looks... After setting it up tomorrow you'll see how easy it is. For now just install and register nncron...