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?
Asked
Active
Viewed 3,061 times
-2

Jamiec
- 133,658
- 13
- 134
- 193

Sahil Verma
- 89
- 1
- 2
- 4
-
4Maybe 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 Answers
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
-
I am gettin following error:The application failed to initialize properly (0xc0000142) – Sahil Verma Dec 22 '10 at 09:59