Is an automatic login with Windows scheduled task possible? - windows

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.

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?

Vbscript is working fine in cmd prompt but not working in task scheduler

I have a vbscript to get the records from Oracle database and need to get those records hourly basis.
When I ran the script from cmd , script is executing fine and getting records through email but when I schedule the same script from task scheduler , showing that task completed fine but records are not getting.
Do we need any permission to access the Oracle database from task scheduler
I have logged in the server with admin user.
Is there another way to schedule this script hourly basis.
Thanks in advance
Thanks
Chandrakiran
Without some code I cannot help you much, I suspect this is an authentication issue however.
Note that the Task Scheduler does not take into account the currently logged in user when running, the script needs to authenticate itself with the database or set the "Run As" user in Task Scheduler if needed.

How to run a VB6 app from a scheduled task without users being able to run it

We have a legacy VB6 application that automatically emails reports. It runs from a scheduled task on a server. Occasionally a user will run the exe - it's in a folder that we can't lock them out of, and it has to remain in that folder for reasons too complicated to go into here. Is there a way to prevent users from running the exe while still letting it run from the scheduled task? I can modify the source code for the exe, so that's an option if someone can help me figure out how.
I'm going to call your existing app AppChild and a new VB6 (or other program language) program AppParent.
Modify AppChild to test for a command line parameter at either Sub Main() or at the first form loaded in the Form_Load() event. If the command line parameter isn't there, AppChild terminates.
AppParent would be in a location not accessible to the other users. The Scheduled task runs AppParent which runs AppChild and passes the required command line parameter. This could be secured somewhat by passing a calculated hash and decoding it in AppChild if needed.
Or, if the users don't have access to the Scheduled Tasks, you could just run AppChild , passing the required parameter from the Scheduled Task. If the users do have access to the Scheduled Task this won't work because they could then see the passed parameter and create a shortcut which passes the required parameter.
You didn't state which OS the server is running but you may have problems using network resources if you try to run the Scheduled Task without a logged in user. Task Manager got a major update to handle security issues to prevent hackers from running tasks without a logged in user. Essentailly, network resources, .e.g. eMail, are not available unless a user is logged in.
https://technet.microsoft.com/en-us/library/cc722152(v=ws.11).aspx
The only way I found around that problem is to run a machine with a user with the correct permissions logged in all the time.
Are you sure you cannot lock the user out?
You could restrict access to the folder so that the user cannot access it and set up the scheduled task to use an account with access to the folder.
Although the users can't be locked out of the folder (perhaps the reports end up in there?), in Windows you can set the permissions on a per file basis. Make a new user that has the full rights (the same as your users). Schedule the VB6 app to run with that user. Remove the rights for the regular users to see the app. You do this by changing the permissions on just the VB6 app.

Scheduled task running under user with concurrent sessions

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.

Create Batch File, Convert to Service, Schedule to Run Daily

I need to run an offsite backup .cmd script (batch file) on a Windows 7/8 PC, daily, whether a user is logged on or not. Naturally, Task Scheduler's feature "run if user is logged or not" doesn't work (sarcasm .. thanks M$) because the user has to be logged on at some time then signed out. Moreover, because of the urgency of the task, it must run no matter what. For example, if the power goes out and upon restoration the computer reboots, there will be nobody logged on. So, I need to convert the batch file to a service.
I've used NSSM to convert the batch file into a service, but I don't know how to make the service run on a schedule, because, by definition, it's not meant to run that way - I should be using a scheduled task. So, I'm not sure what to do and all the tutorials I've seen on Google imply that I know VB script and/or C#. Unfortunately, I don't and don't plan to ... I just need a quick fix to work like a Linux cron job.
Thanks!
Task Scheduler's feature "run if user is logged or not" doesn't work (sarcasm .. thanks M$) because the user has to be logged on at some time then signed out.
Are you sure? Because "run if user is logged or not" is an option, not a trigger. It should be combined with trigger "At startup" to achieve desired result:
If everything else fails, you can use nncron to schedule tasks and install it as service.

Resources