I need to run a console application within the execute method of a timer job in SharePoint 2010. Please guide me to do this by providing samples or links or hints.
1 Answer
Not sure why you would want to run an external application from a SharePoint timer job, however, you could try using the Process() class in C# (this isn't a SharePoint-specific example, but is how you launch external processes from .NET code):
Console.WriteLine("Running");
Process pr = new Process();
pr.StartInfo.FileName = "Notepad.exe";
pr.StartInfo.Arguments = "test.dat";
pr.Start();
while (pr.HasExited == false)
if ((DateTime.Now.Second % 5) == 0)
{ // Show a tick every five seconds.
Console.Write(".");
System.Threading.Thread.Sleep(1000);
}
Sample from: http://omegacoder.com/?p=119
I'm not sure if SharePoint will allow this, but it's worth a shot.