vakar yusuf

vakar yusuf

  • NA
  • 1
  • 0

External Process via windows service

Jul 16 2008 6:04 AM

Can anyone help? I have been struggling with creating a service which calls an external process but it just doesn't work. Please see attached code. The service installs and starts and stops fine but the call to the external process does not work.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;

namespace ExternalCommand
{
    public partial class Service1 : ServiceBase
    {
        public Service1()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            System.Diagnostics.Process.Start(@"c:\windows\system32\notepad.exe");
        }

        protected override void OnStop()
        {
            System.Diagnostics.Process.Start(@"c:\windows\system32\cmd.exe");
        }
    }
}


Answers (1)