Issue with windows tasks scheduler - windows

I want to run powershell script every day and want to use task scheduler for it. But I have to be log in because this srcipt runs cisco vpn client and putty and then runs some python script for one minute. I don't want it to interrupt my work (because it swichs to different vpn etc.) so I set up time to run this task to 2:00 AM and check "run asap after a scheduled start is missed" to make sure that this task will run every morning after I turn on my computer.
But the problem is, that it doesn't run the script after turn on PC and it says event id 332 - Launch condition not met, user not logged-on. I think I understand this problem, it tries to run this script right after start up so at time I'm not log in. But why does not the task try it after 1 minute again up to 3 times? (see below)
What shoud I do to make sure that it will run every day after turn on PC but only once a day (sometimes I need to restart my PC so I don't want it to run again)
There is my task configuration:

Check the 'Run whether the user is logged on or not' and 'Run with highest privilege' options.it will work for you.

Related

How to run a batch file at a specific time and kill it once it runs for a number of hours

I have a bat file which I run with an externally given parameter. It should run for about 6 hours and if the task is still not finished, the process should get killed. I can start the task using Task Scheduler but I'm not sure how to kill it once it reaches the set number of hours. Any idea how I can achieve this?
Thanks.
In Windows Task Scheduler use "Create Task" (not "Create Basic Task").
On the Settings screen there is the option labelled "Stop the task if it runs longer than:".
You can override the length of time.

Windows Task Scheduler wont start task because it thinks previous version is still running

I have an occasional problem (maybe twice a month) were windows task scheduler won't start a new task because it thinks the old version is still running.
The task is a powershell script, it runs all day, every day. The task scheduler starts the script at 5 past midnight every day (UTC), and then the scripts exits itself everyday at 23:55 (UTC). The script does the following actions.
logs its own startup in a database
spends all day reading records from a remote server.
logs its own shutdown at 23:55 every night and exits with 'exit 0'
Task scheduler runs the script with the -NoExit option, so the powershell console remains open on the screen even after the task has exited (allowing a visual check of any output generated)
This all works fine 95% of the time, however, occasionally when the task scheduler attempts to start the new task at 00:05 I see the message 'Launch request ignored, instance already running' in the history. But when I check the log records from the powershell script I see that it started and finished at it's normal time, and I can double check this against the console.
Curiously, on these occasions the task scheduler history indicates that the blocking task finished at about 8am - a time which always corresponds to when I logged on that day.
Any suggestions on what's going wrong and how to sure it? I've already tried tweaking some of the task settings "if the task is already running then the following rule applies - stop the existing instance" but because the fault is intermittent, it's very hard to pin down.
Update - following further testing.
I've tried creating 100s of similar tasks and running them with similar conditions. So far I've reached two conclusions, firstly everything seems to work OK if I remove the -NoExit option. It's almost as if the scheduler has trouble differentiating between the command window, and the PowerShell script itself.
Secondly, everything seems to work ok if increase the gap between the previous schedule dying and the new one starting from about 15 minutes to half an hour or longer. It's as if the task scheduler takes time to work out that the old task has stopped.

Scheduled task fails to run, no error code

We're using a scheduled task to run a simple executable every 2 minutes, it has a working directory set (no quotes round the path) but other than that most options are left as defaults.
Running the task manually by right-clicking on it and selecting Run works just fine, however it never executes automatically. When the time comes to run the task, it just increments the "Next Run Time" field by 2 minutes and that's it. The Last Run Time Field is always the last time the task was manually executed.
The Last Run Result is always 0x0.
I've tried setting it to run as the current user, or as an alternate user set up with administrative privileges and a stored password, but still no luck.
There doesn't appear to be anything immediately obvious in the system event log either to indicate the cause of the failure.
As a bit of background, this is a headless Win10 Pro machine (only ever accessed via LogMeIn) running control software for external hardware. It reboots every morning at 03:00 and since it's on an physically isolated network, automatically logs in to a user account with administrative privileges and no password.
I suspect it may be a permissions issue with the insecure way the system is set up, however at this point there's little to go on.
Any ideas?
Thanks
For posterity, this turned out to be an issue with the way the repetition on the scheduled task was set up. Initially it was set up as a daily task to run every 2 minutes for 24 hours. Whilst this showed the correct next run time in the task scheduler window, for some reason it never executed - Bug?
The fix was instead to set the task up as a one time event that repeats every 2 minutes indefinitely, which seems to be working properly now.

Scheduled task run .bat once a week Win7

I need to have a .bat run once a week when I log onto the computer. I tried several things and if im not logged on then the .bat fails. but works if I am logged on when its scheduled to start. What setting in windows 7 scheduled task makes is keep trying untill I log in? Or am I doing something incorrect?
My settings:
GENERAL:
Run only when user is logged on (Yes)
Configure for: Win7, Win Server 2008 R2
TRIGGER:
Begin the task: On a schedule
Weekly (Yes)
Recur Every : 1 weeks on Tues # 8p
Enabled (Yes)
SETTINGS:
Allow task to be run on demand (Yes)
Run task as soon as possible after a scheduled start is missed (Yes)
If the task fails, restart every... 5 min up to 50 times for 3 days
Thanks!
Did you set up your task to run as you, regardless if you are logged in?
Control Panel -> Task Scheduler. Go to the properties of your task, then under the General tab verify that your user account is specified under the "use the following user account". You will probably also be prompted for your password.
Oooh - sore point! Massive argument with the expert System Administrator at my last job when she couldn't arrange for a scheduled job to start unless the user was logged in. Claimed it was a well-known problem that NO-ONE had ever solved - not even Microsoft (who'd published a fix nearly three years earlier.)
So, I'm not surprised that you're having trouble when an EXPERT (on everything) who'd won industry awards for the quality of her work couldn't get it going.
I think the major problem is in the data you've posted,
GENERAL:
Run only when user is logged on (Yes)
Which just might mean "Run only when the user is logged in."
So - if you'd explain what it is you want to do, we might be able to progress to some conclusion.
Do you want the process to run at a particular time on a particular day, whether the user is logged in or not, or do you want it to run IF the user logs in on that day (but no others) or every 7th day the user logs in or some other condition? Remember - calendar days and work-days are different - public holidays, vacations, whatever come into play...

run a scheduled task in Windows XP without log in

I have been developing a program that needs to be run daily bases. I set this as a scheduled task and put a specific time to run. But it only runs when I log on. Although I unchecked the "Run only if logged on" option, it doesn't run until I log on. My question is, is there any way to run a scheduled task without logging on?
Edit: the program that has to be run daily doesn't have a GUI, it's a visual basic script needs to be run on background.
you will need a service for that, too much to handle in this space, google "windows run program as a service"

Resources