none
run a Console Application within a timer job

    Question

  • Hi

    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.

    Thanks,

     


    smith
    Wednesday, November 30, 2011 6:47 AM

Answers

  • Hi Smithspd

    Here is your reference:

    public override void Execute(Guid targetInstanceId)
    {            
    
    base.Execute(targetInstanceId);
    
    string _path = Path.Combine(Microsoft.SharePoint.Utilities.SPUtility.GetGenericSetupPath(string.Empty), "YOUR_PATH_FILE");
                        
    ProcessStartInfo psi = new ProcessStartInfo(); 
    psi.CreateNoWindow = true;
    psi.UseShellExecute = false; 
    psi.FileName = _path;
    psi.UserName = _uname;
    psi.Password = _upass;
    psi.Domain = _udomain;
    
    Process p = new Process();
    p.StartInfo = psi;
    p.Start();
    
    }
    


    Note: put this code into the Job Definition class and inherit SPJobDefinition class. 

     

    Hope this help.

    /H


    Visit my blog: http://tuan-tomy.blogspot.com | Visit my forum: http://sharepointvietnam.net | http://store.bamboosolutions.com
    • Marked as answer by Shimin Huang Wednesday, December 7, 2011 9:34 AM
    Wednesday, November 30, 2011 7:16 AM
  • Hi Smithspd

    It does not make sense to run a console application withing a timer job execution .you can just create new timer job and let timer job execute the code instead of Console application.

    Regards.


    Ahmed Naji SharePoint Geek
    MCP|MCTS
    My Blog | DotnetFinder
    • Marked as answer by Shimin Huang Wednesday, December 7, 2011 9:34 AM
    Wednesday, November 30, 2011 7:18 AM

All replies

  • Hi Smithspd

    Here is your reference:

    public override void Execute(Guid targetInstanceId)
    {            
    
    base.Execute(targetInstanceId);
    
    string _path = Path.Combine(Microsoft.SharePoint.Utilities.SPUtility.GetGenericSetupPath(string.Empty), "YOUR_PATH_FILE");
                        
    ProcessStartInfo psi = new ProcessStartInfo(); 
    psi.CreateNoWindow = true;
    psi.UseShellExecute = false; 
    psi.FileName = _path;
    psi.UserName = _uname;
    psi.Password = _upass;
    psi.Domain = _udomain;
    
    Process p = new Process();
    p.StartInfo = psi;
    p.Start();
    
    }
    


    Note: put this code into the Job Definition class and inherit SPJobDefinition class. 

     

    Hope this help.

    /H


    Visit my blog: http://tuan-tomy.blogspot.com | Visit my forum: http://sharepointvietnam.net | http://store.bamboosolutions.com
    • Marked as answer by Shimin Huang Wednesday, December 7, 2011 9:34 AM
    Wednesday, November 30, 2011 7:16 AM
  • Hi Smithspd

    It does not make sense to run a console application withing a timer job execution .you can just create new timer job and let timer job execute the code instead of Console application.

    Regards.


    Ahmed Naji SharePoint Geek
    MCP|MCTS
    My Blog | DotnetFinder
    • Marked as answer by Shimin Huang Wednesday, December 7, 2011 9:34 AM
    Wednesday, November 30, 2011 7:18 AM