473,386 Members | 1,741 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Using C# to create a scheduled job

I need to create an executible that will run on a nightly basis.

The executible is a simple command line statement like:

OSQL -Usa -PmyPasword -n -Q "BACKUP DATABASE msdb TO DISK =
'c:\msdb.dat_bak'"
Is it possible to use C# to create an executible that will run this command
line statement on a scheduled basis?

If so, can anyone give me some general ideas on how to go about this?
Nov 16 '05 #1
2 7789
Hello Dave,

Why do you want to do this from C#?
Why don't rather just add a scheduled task?
Or in SQL create a scheduled job?

If you really want to execute this from C# use Process:

System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = "OSQL.exe";
myProcess.StartInfo.WorkingDirectory = "C:\";
myProcess.StartInfo.Arguments = "-Usa -PmyPasword -n -Q \"BACKUP DATABASE msdb TO DISK = > 'c:\msdb.dat_bak'\"";
myProcess.Start();

out of memory, so it might be buggy, but give it a try.

Cheers

Pieter
I need to create an executible that will run on a nightly basis.

The executible is a simple command line statement like:

OSQL -Usa -PmyPasword -n -Q "BACKUP DATABASE msdb TO DISK =
'c:\msdb.dat_bak'"

Is it possible to use C# to create an executible that will run this
command line statement on a scheduled basis?

If so, can anyone give me some general ideas on how to go about this?


Nov 16 '05 #2
Hi Dave,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to start a job in schedule
tasks using C#. If there is any misunderstanding, please feel free to let
me know.

To achieve this, you can either use Process.Start or WMI. The following
thread is a talking on this issue. HTH.

http://groups.google.com/groups?hl=e...sPfvzBHA.1712%
40tkmsftngp04&rnum=2&prev=/groups%3Fq%3Dschedule%2Btask%2BC%2523%2Badd%26hl%
3Den%26lr%3D%26c2coff%3D1%26selm%3DOw6sPfvzBHA.171 2%2540tkmsftngp04%26rnum%3
D2

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Bart Simpson | last post by:
Hi, I want to control 'Scheduled Tasks' in Windows 2003 by python program. But I couldn't find any Python module about win32 'Scheduled Tasks'. I could find only Perl module about it. (see...
9
by: Lauren Quantrell | last post by:
Is there a way to create a text file (such as a Windows Notepad file) by using a trigger on a table? What I want to do is to send a row of information to a table where the table: tblFileData has...
14
by: Mark C. | last post by:
I'm trying to call a batch file that I've built using the FileSystemObject and CreateObject("Wscript.Shell"), oShell.Run... in an asp script. Naturally, I can get the script to work from a command...
10
by: teddysnips | last post by:
Application is a Work Tracking/Timesheet database. The increments of work are stored in the TimesheetItem table. This contains, inter alia, the Work Code, the Start and the Duration that the...
0
by: gwaddell | last post by:
I have a stored procedure that is loading data into a global temp table. Here is all the code for that stored procedure. CREATE PROCEDURE AS SET NOCOUNT ON BEGIN
3
by: nkunapa | last post by:
Hi: I am looking for any ideas/comments/suggestions on how a Windows Service kind of functionality can be acheived from a web application which which will run under IIS or for that matter any...
2
by: mpriem | last post by:
Hi there, I've developed a reporting website in the past using a Windows Service which periodically queried network hosts for data and produced a XML report which could be parsed by a ASP...
1
by: Prof. William Battersea | last post by:
I'd like a class method to fire every n seconds. I tried this: class Timed: def.__init__(self): self.t = Timer(3, self.dothing) def.start(self): self.t.start()
4
by: Magnus.Moraberg | last post by:
Hi, I'm working on a Windows 2000 machine which hosts a SQL 2005 Express Database. This database is backed up using the following method - http://www.sqldbatips.com/showarticle.asp?ID=27 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.