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!
Powershell's
get-content -wait
will follow a file liketail -f
If you're looking for something similar to tail you could use the more command or the type command.
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?
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 :)