I have a C# console application that processes data. The problem is that when I log off, the console application ends. If I schedule the application to run at a set time and I am not logged in, the application does not run at all. I can run it interactively by double clicking the .exe file, and I can open Task Scheduler and run it by right clicking and selecting run. As soon as I log out, the application ends.
For XP/Windows Server 2003 open your Scheduled Task and make sure the 'Run only if logged on' checkbox is cleared.
For Windows 2008 select the 'Run whether the user is logged on or not' option.
Set up the application to run using the Windows Task Scheduler. This can allow an application to run whether or not a user is logged in.
Create a windows service that runs under the system account
If I have a long-running task that is still working when I need to leave, I simply lock the screen using Windows-L
and leave myself logged in. If this works, it's a much simpler solution than setting up a scheduled task every time you want to run a particular job, especially if you need to supply different parameters each time.
I realize that this may not always be possible -- you may have corporate rules that disallow this or may be using a shared computer where the next person needs access to the console (though running a scheduled task in the background surely won't make them any happier), but I offer it as a simple solution for most single-user computer scenarios. IMO, scheduled tasks are best used for just that, scheduled tasks, i.e., something you want to automate to run on a regular basis. If this describes your scenario, then by all means use one. Likewise, if what you really have is a service that runs continually and responds to requests, then use a Windows Service. If you just want to have your job keep running and secure your computer until it finishes, then locking the computer is the best way to go usually.
I have very similar situation. Try to set "start in" parameter in Action tab (Properties of task). Of course You should type in path to Directiory where You have Your application.
© 2022 - 2024 — McMap. All rights reserved.