2

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!

4 Answers 4

1

Powershell's get-content -wait will follow a file like tail -f

0

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
1
  • Will any of these "follow" the log file the way tail -f does?
    – voretaq7
    Aug 30, 2012 at 23:05
0

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?

0

Im a little confused.. you only 'switch' to these machines occasionally, do not want to install tail.exe, yet you are installing a scheduled task?

A few ideas come to mind:

1) Place tail.exe on a network location, and use it directly. Given the UID is SYSTEM, the network share just needs $COMPUTERNAME access, i think the group is Users as opposed to Authorized Users, or vice-versa

2) Run the job itself on the user desktop: Use psexec. It has an -i(nteractive) option. So, psexec -accepteula -s -i cmd /k echo hello. You can omit the -s if the sched job is already providing system. Also, the /k is just for proof of concept, you would want to use /c normaly.

3) Write a program :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .