Creating VS 2010 executable for Daily Tasks - c#

I want to create an executable in VS 2010. This executable will be create an excel spreadsheet and will transfer that file via FTP. I want this executable to be fired off via Windows tasks.
What is the best way to accomplish this? Would I create a regular windows form application, dll, or Empty Project, or windows service?
Thank you in advance for any assistance.

A plain old console application scheduled with the task scheduler should do the trick.

If you need the application to run when a computer is turned on but no one is logged in, create a service. If your application runs only when someone is logged in, but has no UI, use a console application. If your application runs only when someone is logged in and has a UI, use a Winforms app.

I'm not sure what the current best practice is, but in our shop we create console applications and use the task scheduler to execute them.
A library (dll) won't be executable from the task scheduler AFAIK, and a WinForms app isn't very useful for any app that runs automatically (i.e.: doesn't require user interaction).
A service would be appropriate for an application that needs to respond to system events/changes when they occur, which doesn't sound like your use case.

Related

How to automate a windows form application without windows scheduler?

I need to make an application which automatically moves files from source folder to destination folder on specified "time"(2 different times in a day). Once entered, this app should run daily. I have made a form application which moves file perfectly on button click. I need to implement this without any button click interaction.
Scheduling using Windows Task Scheduler is not an option for me.
One way I have achieved exactly that by creating a windows service project and put all the button click logic in a class library.
For scheduling the service i used Quartz.Net so that it can triggers the job/service at given interval.
You can find more about Quarts.Net here.
Please do note that you need administrative access to install and run your windows service.

Start .Net Application After Logging in

I need to create an .Net application which is automatically start after windows logging in. on that time i dont want to show our desktop and windows related things.
Is it possible?I need to create one more layer between login and our Windows.That layer is our .Net Application
I don't quite get it. It is either a Windows Service, which is an application that runs in the background all the time, or some kind of a Kiosk application, which sits "on top" of everything and is effectively the only UI to the PC.
You can start make a Schedule Task and run it
http://windows.microsoft.com/en-au/windows/schedule-task#1TC=windows-7
p.s you can only can run cmd files

Create a process not an application in C#

I've created a simple application that I wish to be a process and not show up as an application inside taskmanager, simply because it is not an application. It was intended to be a process.
You might want to read about Windows Services.
Walkthrough: Creating a Windows Service Application in the Component Designer
Creating a C# Service Step-by-Step: Lesson I
You don't give much information about what you application does, but either Console or Forms will be displayed on the TaskManager, and even as a process it will be shown over the Processes tab so I'm not sure what are your intentions with this.

c# main project and service

Despite my thorough googling, I am still confused on this matter.
Let me explain my situation. I created a c# project which gives the user the ability to back up the database manually (via a button click). Now the user must be able to schedule a time at which the database back up will run automatically. To achieve this, I am planning on creating a service which is started via the windows scheduler when the set back up time is reached.
I will need the deploy the service along with the main project (In my head, the service will be a different project. Maybe I am wrong here.).
My question is how do I deploy the service when the user installs the main project?
PS: I am using c# express and sql 2008 R2 express.
What are you using to install the main application. Chances are you the said packaging tool will also have hooks for allowing you to install the service. For example, if you are using Wix to create a msi package to install the main application, then you can configure Wix to also install the service.
This google search will point you to relevant articles for the same.
If instead you are not using any installer tool, say you simply give the user a zip containing all executables, then you will need to manually install the service. This article is perfect to create a self installable service. You could use Process.Start to execute the installutil exe to acutally install/uninstall the service.
Edit1:
Building on Rup's comment to your question, you already have the code required to backup the database. All you need, is to be able to schedule this. Once the user enters a schedule in your UI, you can create the corresponding task in the Task Scheduler. Have that task execute your main application, passing in the argument -backup "dbName" or what ever info is needed for the before mentioned backup code to run.
You may use the following template [which is meant for a console app, but will work just fine for your gui app as well. All you will need to check is if any switches have been passed in, then do not start the gui, instead simple execute the backup function code.] ... There are also a lot of existing questions on StackOverflow on which commandline parsing tool to use ...
The approach I would take is create the project for the UI, create a project for the service. The service would be a windows service that would always be running and would be responsible for creating the scheduled task. (Rather than having a scheduled task start the service.) How you go about creating the scheduled task is fairly open, you could shell out AT, or you could do some COM interop with the TaskScheduler type libs. I hope this helps.

C# program without UI

Is it possible to make a Visual C# program that runs without a console or windows form? If so, how?
Sure- set the build output type to Windows Application under Project Properties, and don't show a form in Main. You can do whatever you want in there- you just have to manage the lifetime of the app somehow (eg, how do you plan to shut it down?)
You can also create a Windows Service app; start and stop the app via the Services Management console.

Categories