473,748 Members | 11,145 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_ba k'"
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 7821
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.Diagnost ics.Process myProcess = new System.Diagnost ics.Process();
myProcess.Start Info.FileName = "OSQL.exe";
myProcess.Start Info.WorkingDir ectory = "C:\";
myProcess.Start Info.Arguments = "-Usa -PmyPasword -n -Q \"BACKUP DATABASE msdb TO DISK = > 'c:\msdb.dat_ba k'\"";
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_ba k'"

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 misunderstandin g, 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&r num=2&prev=/groups%3Fq%3Dsc hedule%2Btask%2 BC%2523%2Badd%2 6hl%
3Den%26lr%3D%26 c2coff%3D1%26se lm%3DOw6sPfvzBH A.1712%2540tkms ftngp04%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
4775
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 http://taskscheduler.sourceforge.net) But, I want to control 'Scheduled Tasks' by python :) Is there any python module about win32 'Scheduled Tasks'?
9
11233
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 only one column: txtOutput I want to use the DB front end (MS Access) to send the text string to the SQL backend, then have the SQL Server create a file to a path, such as F:/myfiledate.txt that holds the text in txtOutput, then the trigger...
14
3558
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 line but not from a browser. The page does not throw an error but the oShell.Run... portion of the script doesn't run. Any help would be appreciated. Thanks.
10
2131
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 employee spent that day on a particular project. Some employees in the Network Support Department don't complete a standard 7.5 hour day for various reasons, so for every Network Support person I need to update these particular days with an amount...
0
2601
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
2146
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 application server say Tomcat. I have a Windows service which should run every half hour and call four different methods in a Web Service in serial mode. The methods will have to wait for the previous one to finish and if the previous one is a really...
2
1573
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 website. I want to rebuild this reportingsite using C# and ASP.NET and get rid of the Windows Service. My question is:
1
1813
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
4134
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 As part of this method, I have a Task which is scheduled to run once a
0
8828
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9367
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9319
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2213
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.