Nightly job... a Console App? Windows Service? Other?

R

rcook349

I want to run a piece of C# code at midnight every night that opens a file,
changes something in it, and saves it.

Would this be a Console Application set up as some sort of job? Would it be
a Windows Service?

Thanks,
Ron
 
K

Kerem Gümrükcü

Hi Ron,

this depends on the environment. If you are logged-in,
then i recommend a windowless forms application e.g
writing its progress to windows system logs or a own
logfile or a console to display its progress status, or
a form with some textbox to show its working progress.
If you are not logged in, this means that you system
just runs without any user, then you are depending
on a Windows Service, but also here i recommend to
write some debugging data/progress to either the
system logs or to a own logfile. You also must
take care of user rights/permissions on accessing
an operating on the file.

I personally would use a service, since this you
can trust, the service i mean. It will run always
whether you are logged in or not,...

Regards

Kerem

--
 
M

Mel Weaver

If the machine is logged on write a console app and use the task scheduler
to run it.
 
J

John Duval

I want to run a piece of C# code at midnight every night that opens a file,
changes something in it, and saves it.

Would this be a Console Application set up as some sort of job?  Would it be
a Windows Service?

Thanks,
Ron

Hi Ron,
For something simple, you could just use the AT command (or use
Scheduled Tasks UI) and have it kick off your app:
C:>at 14:11 /interactive "MyApp.exe"

Just be aware that it's going to run with different credentials (much
like a service), so if you're accessing a network share or something,
you might run into access issues. Also take a look at the
"interactive" flag if you need it to interact with the desktop of the
logged in user.
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top