-2

System.Diagnostics.Process.Start(@"C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe") is not working when executed from a timer Event of a Windows Service?

Jamiec
  • 133,658
  • 13
  • 134
  • 193
Sahil Verma
  • 89
  • 1
  • 2
  • 4
  • 4
    Maybe you'd like to elaborate on how it's "not working". E.g. is an exception being thrown? – Reddog Dec 22 '10 at 09:52

3 Answers3

3

This code possible will help for your System.Diagnostics.Process.Start Class

using System;
using System.Diagnostics;
using System.ComponentModel;

namespace MyProcessSample
{
    class MyProcess
    {
        public static void Main()
        {
            Process myProcess = new Process();

            try
            {
                myProcess.StartInfo.UseShellExecute = false;
                // You can start any process, HelloWorld is a do-nothing example.
                myProcess.StartInfo.FileName = "C:\\HelloWorld.exe";
                myProcess.StartInfo.CreateNoWindow = true;
                myProcess.Start();
                // This code assumes the process you are starting will terminate itself. 
                // Given that is is started without a window so you cannot terminate it 
                // on the desktop, it must terminate itself or you can do it programmatically
                // from this application using the Kill method.
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
    }
}
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
2

Windows services run outside of a user's interactive session, so although executing a process is possible, you shouldnt expect a new window to open (in your case an instance of acrobat reader).

In addition, you will often have security restrictions as to what you can or can't do based on which user the service is running as.

Jamiec
  • 133,658
  • 13
  • 134
  • 193
0

Check out these posts and many others around the place. Windows Services are not generally intended for interactivity and will have all sorts of security issues depending on who they are running as.

Community
  • 1
  • 1
Reddog
  • 15,219
  • 3
  • 51
  • 63