I have a relatively simple C# application which grabs some data from a website and writes it into an sdf database file.
The application itself works just fine - however if i run the application as a scheduled task with the windows task scheduler it does not add anything to the database (it still shows up as running in the task manager, as intended).
So just to clarify it again:
Manually starting the exe works just fine (click or command window), but starting it as a task (no matter if scheduled or manually) it runs but does not add anything to the database.
What differences are there between starting an exe manually compared to a task which has a "start program" action?
Sadly this is not really the perfect answer for the question, but I have now got it working by using an SQL Server (MS-SQL 2014 Express).
Apparently .sdf files and the windows task scheduler aren't best friends.
Related
In the moment I am running a sql server database locally. Besides I have scheduled a .exe (programmed in c#) via Windows Task Scheduler that is running every night (computer running 24/7) and is downloading an .csv from a external website.
Another .exe is then running every morning to parse this .csv and inserting data into local sql database.
As this is not really "professional" and I am seeking for better solutions I have subscribed for aws.
Question is if above scenario can be done in aws with native methods?
You can run Windows Server 2012 on an EC2 server. Then you can install your EXE on that server and run it via Windows Task Scheduler.
If you want to run your program without a Windows server then you might want to look into Microsoft Azure Functions which is similar to AWS Lambda but with support for the Microsoft ecosystem.
I need to write an application that run in the background (i.e., invisible to user). It should be always running when the server is on, regardless of user login or off. Or at least it should run on schedule (e.g., hourly). It also should still run after the server shut down and turn on again.
The application is used to backup some data from one server (linux) to the local server where the application run (windows server).
From my research, many suggest to use Window Service. But I'm newbie on C# and also on this area like Window Service.
Can anyone direct me where I should start?
Is Window Service a suitable solution? Or if there is better solution? Please explain.
Thank you in advance.
[CLOSED]
Thank you for all who has responded.
Yes, the best practice is windows services.
However, if your operations are simple enough to write in DOS batch file. You can schedule your task in windows task scheduler. It will save a lot of time and is easy to setup.
UPDATE (FYI)
I have a batch_update.sql file that needs to be executed at 1.00AM every day. I created batch_update.sql file and a batch file batch_update.bat in C:\bat.
batch_update.sql includes all SQL operations.
batch_update.bat calls batch_update.sql file to execute it as follow.
sqlcmd -U adminuser -P password -S (local) -i C:\bat\batch_update.bat -o C:\bat\batch_update.txt
Then I created a task in windows task scheduler to run at 1.00AM which works pretty well.
A windows service definitely sounds like the long term solution. For simplicity however, you could create a command line project in C# and then use windows scheduler to run it in whatever intervals you like.
I recommend windows service too, you can have some information right here.
Yes, Windows Service is the solution you're looking for. Here's a good starting point on MSDN.
I work on an application coded in c# (.net framework 4) and that accesses a database and reads/writes some tables.
When I run the app on the development machine it runs ok (tables are well written).
When I run the app on windows server 2003 outside task scheduler, it runs ok (tables are well written).
When I run the app on from windows task scheduler, it does not run ok (tables are not written at all).
I tried many accounts, and event the administrator one, to launch the task in task scheduler, but any account does not work.
I must write that an older version of the application runs ok on development machine, on windows server 2003 with/without windows task scheduler (tables are well written).
Any idea ?
Thanks
The only thing I would recommend is to add lines:
Debugger.Break();
Debugger.Launch();
right where actual connection has to be opened and debug the application.
With this amount of information there's nothing else to advise.
I have a ASP.net web application that checks the status of my servers, it then wraps all this information up and puts it in a email. My Question how do I run this automatically say every day at like 2:00am, or like every 12 Hours?
Thanks
The best solution is to create a simple MS Windows Service which will do this job.
You'd better implement this as a separate process from your ASP.NET application. Phil Haack has summarized the reasons in this blog post. A Windows service for example or even a console application using the windows scheduler could work just fine for this task.
You want a scheduler - I recommend Quartz.NET.
As others have said, your code doesn't have to be in a web app.
If it is, then schedule a job that uses WebClient to make a request to your web app.
Check out WebDriver.
It's intended as a test / qa framework, but there's nothing stopping you from using it in a console application, which you can then run as a Scheduled Task. Note that whatever machine runs the Scheduled Task has to have a browser that WebDriver can fire up.
The easiest solution would be to create a scheduled task on your server using the Windows Task Scheduler and setup this job so that it uses internet explorer to visit your webpage.
If you open the task scheduler and create a new task. In the "Run" field put:
"C:\Program Files\Internet Explorer\IEXPLORE.EXE""http://www.yoursite.com/yourpage.aspx"
Then in the "Start in" field put:
"C:\Program Files\Internet Explorer"
Now configure this task to run at 2:00am every day.
I have a task scheduler which runs a C# console application every minute. It runs the .application file via a .bat file and does so successfully for a period of time before stopping completely.
Un-installing/re-installing my console application doesn't fix the problem and the task scheduler is showing the batch file as succesfully executing. Also, running the program manually works just fine.
My questions are:
How can I get this task to run again via the task scheduler. I have tried deleting and re-creating the task, uninstalling/reinstalling the applcation.
I have a scheduled backup task occuring around the time the application stops working. Volume shadow copy is not enabled. Could this be impacting my application and why?
In the task scheduler take a look at the Settings tab. You will find an option "If the task fails, restart every".
By default (this is not checked) then if your task fails it will not be run again. You can check your task history to see if it has failed. In any case it sounds like you want to be run again even if it failed the last time it ran.
This is the option you want to change.
Despite the help, I did not manage to isolate the cause of this problem.
I have re-developed my scheduler using Quartz.NET and it's now running as a Windows service.