I am auto creating scheduled tasks with this line within a batch windows script:

schtasks /Create /RU SYSTEM /RP SYSTEM /TN startup-task-%%i /TR %SPEEDWAY_DIR%\%TARGET_DIR%%%i\%STARTUPFILE% /SC HOURLY /MO 1 /ST 17:%%i1:00

I wanted to avoid using specific user credentials and thus decided to use SYSTEM.

Now, when checking in the taskmanagers process list or, even better, directly with the

C:\> schtasks

command itself, all is working well, the tasks are running as intended.

However in this particular case I would like to have an open console window where I can see the log flying by.

I know I could use

C:\> tail -f thelogfile.log

if I installed e.g. cygwin (on all machines) or some proprietary tools like Baretail on Windows. But since I only switch to these machines in case of trouble, I would prefer to start the scheduled task in such a way that every user immediately sees the log.

Any chance?

Thanks!

link|improve this question

67% accept rate
feedback

2 Answers

If you're looking for something similar to tail you could use the more command or the type command.

C:\>more /?
Displays output one screen at a time.

MORE [/E [/C] [/P] [/S] [/Tn] [+n]] < [drive:][path]filename
command-name | MORE [/E [/C] [/P] [/S] [/Tn] [+n]]
MORE /E [/C] [/P] [/S] [/Tn] [+n] [files]

    [drive:][path]filename  Specifies a file to display one
                            screen at a time.

    command-name            Specifies a command whose output
                            will be displayed.

    /E      Enable extended features
    /C      Clear screen before displaying page
    /P      Expand FormFeed characters
    /S      Squeeze multiple blank lines into a single line
    /Tn     Expand tabs to n spaces (default 8)

            Switches can be present in the MORE environment
            variable.

    +n      Start displaying the first file at line n

    files   List of files to be displayed. Files in the list
            are separated by blanks.

    If extended features are enabled, the following commands
    are accepted at the -- More -- prompt:

    P n     Display next n lines
    S n     Skip next n lines
    F       Display next file
    Q       Quit
    =       Show line number
    ?       Show help line
    <space> Display next page
    <ret>   Display next line
link|improve this answer
feedback

One possible way of achieving it would be to create a task running as the logged-on user at login using schtasks. The task would run a batch file, with the last bit of the batch file deleting the task and creating another.

You might also want to do some checking to see if the user has logged off (creativity may be required there) as you don't need their tasks to keep running while the machine is at a logon screen or someone else is logged on.

If they don't have access to run the original process, you could run it using your original schtasks job, then just make the user's batch file read the output.

Hopefully that's clear?

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.