Scheduled task running under user with concurrent sessions - windows

If I make a scheduled task that checks if a particular window is open, and it runs under a user (e.g. user "foo") with multiple sessions (e.g. 3 people are logged on the server as user "foo" at the same time), would that task check for the window in all the sessions?

I wrote a bat file that runs cmd.exe and ran it from task scheduler. There were two users logged on under the same username at the time, and running the scheduled task under that username ran only one cmd.exe process according to task manager. It looks like a scheduled task runs under one session but not all sessions.

Related

How to make scheduled task run program GUI/interactively WITHOUT user logon

There's a test that needs to be run on Windows interactively.
Now I have a PSSession to create a scheduled task for that.
But I just realized the scheduled task for an interactive run only works when a user logon.
Is it possible to bypass this kind of limitation?
I tried to google whether the scheduled task could run a GUI program without logon, or how to create a logon session programmatically but I failed to get helpful information.
Could anyone help me?

Is an automatic login with Windows scheduled task possible?

I need to run a python script every day at a certain time. Said script takes screenshots and sends them to me in the mail. I have a .bat that executes the script, and I have created a scheduled task to execute the script, the problem is that if the user is not logged in, the screenshots fail.
Is there any way to do an automatic login with username and password through a Windows scheduled task at a specific time?
I have been reading and it is not clear to me, it seems that not, but I was sure that something like this could be done.
This is the scheduled task that I currently have. I need that before it is executed, it is logged in with the user.

How to keep a task running in task scheduler despite password change

I have a windows task running on windows server via Task scheduler. It is scheduled to run indefinitely. When the server password is expired after set period or is changed, the task stops running and then we have to change the password in task scheduler for keeping it running. Is there any way we can remove this dependency of password in task scheduler.
the only thing I think would work is to connect it to some password manager, and read from there (I know we did something like this with https://www.passwordstore.org/)
then you only need to have your own accepted gpg keys to read from there

Start application on windows startup / boot but allow it visible to users when logged in?

I've tried using Scheduled Tasks using "Run whether user is logged on or not", but it appears to run the application in a separate instance even if its started when the user is logged in already.
Is there a way to do this programatically? Does windows allow this at all or will I need to stop the program(s) and restart them under the user credentials?
Your problem is that the tasks are launched as background tasks so the user cannot access them.
You should launch cmd.exe via "the Sheduled Tasks" and launch your application through cmd (passing it by parameters).
see : How to launch cmd.exe to execute command using Task Scheduler ?

Kill a process tree from task scheduled windows batch file

I have created a Windows Task that runs on Admin account with highest privileges that runs a batch file every minute.
This batch file will execute a PHP script to retrieve a webpage , after which it checks if no page or wrong content is returned.
If the result is negative then the batch routine kills the httpd process and its children using taskkill (I am currently dealing with a PHP hang causing the Apache Http process to hang as well).
This entire process works perfectly when executed while logged onto the machine as admin. However when executing as a task (and despite admin privileges) the process does NOT get killed. There is no event or debug entry.
So my question is why is task kill unable to kill the process, how can I get more info and what alternatives exist?

Resources