473,516 Members | 3,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating Event Trigger in Task Scheduler

1 New Member
I am new to programming and I have found a code to register a task under root folder in task scheduler.
I have the below code in which there is a method "eTrigger.SetBasic("Security", "Microsoft Windows security auditing.", 4625)" what it does is it creates a duplicate "Log Name" and "Log Source" and bottom line my code does not work.
I want to use eTrigger.GetBasic() or eTrigger.Subscription to address my code to the actual event logs. When I use eTRigger.GetBasic() it with the arguments I am giving in eTRigger.SetBasic("Security", "Microsoft Windows security auditing.", 4625) it gives me error

Can someone fix this code for me?


Expand|Select|Wrap|Line Numbers
  1. class Program
  2. {
  3.     static void Main(string[] args)
  4.     {
  5.  
  6.         using (TaskService ts = new TaskService())
  7.         {
  8.             // Create a new task definition and assign properties
  9.             TaskDefinition td = ts.NewTask();
  10.             td.RegistrationInfo.Description = "Does something";
  11.             // Create a trigger that will fire the task at this time every other day
  12.             // whether user is logged on or not
  13.             EventTrigger eTrigger = (EventTrigger)td.Triggers.Add(new EventTrigger());
  14.             EventLog securityLog = new EventLog("Security", System.Environment.MachineName);
  15.             //this is where I see problem. I want to use eTrigger.GetBasic
  16.             eTrigger.SetBasic("Security", "Microsoft Windows security auditing.", 4625);
  17.             eTrigger.Enabled = true;
  18.             eTrigger.ExecutionTimeLimit = TimeSpan.Zero;
  19.             // Create an action that will launch Notepad whenever the trigger fires
  20.             td.Actions.Add(new ExecAction(@"C:\Windows\notepad.exe"));
  21.             // Register the task in the root folder
  22.             ts.RootFolder.RegisterTaskDefinition("test", td);
  23.         }
  24.     }
  25. }
Apr 28 '14 #1
0 1332

Sign in to post your reply or Sign up for a free account.

Similar topics

1
9652
by: Faiz | last post by:
We have developed an application in VB6 (say AA.exe). We wish to schedule the execution of this application (AA.exe) through Windows Task Scheduler. Is there a way through which we can add this application (AA.exe) to Task Scheduler by using another application (say BB.exe), which is also developed using VB6? The operating systems can be...
4
2273
by: Christina | last post by:
Dear All, How can I pop up the windows task scheduler inside of my .net application? Such as I have a button called Schedule Now, after clicking it, the Add Scheduled Task window will pop up, just like clicking from Control Panel -> Scheduled Task -> Add Scheduled Task. Appreciate ahead for any of your suggestions. Thanks.
2
3527
by: Kevin | last post by:
Hi, I am looking for a Task Scheduler with source code that has the following features: - Must perform all of the same functions as the Windows Task Scheduler - Must be able to run COM Objects - Must be able to send email and log to the Windows Event Log - A web interface would be a real nice feature - It would be great if it was XML...
7
15186
by: Shane Story | last post by:
Have an app and would like to allow easy addition of MYAPP.EXE /F /P (for example) my prog with command line args, as a job to be run. Would like to make it easier on the user to run the app. I want to have it run automatically as specified by the user. What is the best thing to do and what platforms would it limit me to?
2
2853
by: microsoft.private.windows.netserver.setup | last post by:
Hello, I was wondering if someone can help. I have built a VB.NET application that is just a simple .exe which calls Excel and inputs some data. But when run in a Task Scheduler setting, the application will only run if a console session is logged in, ie: logged into the computer. If I logout of the session, and let Task Scheduler run, it...
11
15376
by: Max | last post by:
I'm writing a program that needs to be able to create custom .job files and add them to the scheduled tasks folder. What I'd like to know is, what is the format of a .job file and how do I go about adding in all the data so that the task could run correctly? If that is something not so easy to do, then say I need a certain part of my...
3
2224
by: mayur_hirpara | last post by:
Hi, I am writing a VB.NET application. It is a Windows application at the moment. The application contains a button. the click event of button perform a long running task. It needs to be started by windows task scheduler to carry out some operation. When I am testing the application I want to differentiate if the "differentiate between a...
4
2695
by: Sid Price | last post by:
Is there a .NET (2003) class available somewhere that might provide a comprehensive task scheduler with a better granularity than the one minute of the built-in scheduler on XP? Even down to 15 seconds would be better than one minute. Sid.
1
4486
by: Cupric | last post by:
I have a python script that runs fine from the command line or from within IDLE, but doesn't work through the Vista Task Scheduler. The script downloads some csv files and then uses pywin32 to combine the csv files into a single document. When I run it through the task scheduler, it downloads the csv files, but then doesn't seem to launch...
0
944
by: roblee | last post by:
My network consists of one laptop with Windows Vista OS and one Desktop with Windows 8 OS. I use Task Scheduler on each of these machines to start programs based on a schedule. I want to create a task on the Windows 8 machine that starts a program based on an event that occurs on the Vista machine. Can this be done in Task Scheduler?
0
7273
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7405
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7574
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...
1
7136
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...
0
7547
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5106
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...
0
1620
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
487
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...

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.