0

I run another program from Windows Service

private Process RunApp(string _appLocation)
    {
        //Create Process
        Process _ret = new Process();

        _ret.StartInfo.FileName = _appLocation;
        //Run as Administrator.
        _ret.StartInfo.Verb = "runas";
        //Window = normal
        _ret.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
        _ret.StartInfo.CreateNoWindow = false;

        _ret.Start();
        return _ret;
    }

I see it in Task Manager. it is working but I can't see window.

(If I can not see this then I can change Parent and see it)I try this: Create new MidiChildWindow project and:

    [DllImport("user32.dll", SetLastError = true)]
    static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
    [DllImport("user32.dll")]
    static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

    private void GetListeners()
    {
        Process[] Memory = Process.GetProcesses();

        foreach (Process _prc in Memory)
        {
            if (_prc.ProcessName == "MyRunnedApplication")
            {
                SetParent(_prc.MainWindowHandle, this.Handle);
                ShowWindow(_prc.MainWindowHandle, 1);
            }
        }
    }

but its not work. Runned my application is child the Windows service and I can not change it.

How I see it? (Sory my bad english)

VolkanCetinkaya
  • 645
  • 7
  • 13
  • This is expected behavior, and protects you against *shatter* attacks. – Ben Voigt Jun 04 '15 at 15:09
  • possible duplicate of [Starting an Application from Windows Service](http://stackoverflow.com/questions/7601558/starting-an-application-from-windows-service) and http://stackoverflow.com/q/8262236/103167 – Ben Voigt Jun 04 '15 at 15:11

0 Answers0