Search code examples
batch-filescheduled-taskswindows-server

Run .bat script on server start up and keep console


I can schedule a .bat script to be executed on system start up in Windows Server using Scheduled tasks in control panel and specify a user to perform this execution on behalf of.

But when this script starts and runs other programs they all are invisible for me even when i log into the system. I see them in task manager and there is only one user session established.

They question is, whether there is a way to make these consoles and applications visible, so I can see execution process and stop it if required?


Solution

  • As long as your user has administrator privileges, this is quite simple: There is a button on the left bottom side of taskmanager where you can "show processes from all users"

    I am doing this everyday...

    If you are interested in the output of stdout from each program, you have to pipe it into a textfile/logfile.

    for creating and writing to a new logfile use:

    program.exe > logfile.txt
    

    for appending to a existing one use:

    program.exe >> logfile.txt
    

    Use a logfile roller like tail (http://tailforwin32.sourceforge.net/) to watch these logfiles while the programs are executed.

    Beside of that, I don't think, that it is possible to get UI Outputs from another user onto your screen without logging in as this user. But if you are really logged in on the same user session, I think program UIs should pop-up when a script executes the program.