How to open cmd from windows service?

I am creating a Windows service and using C #. I want to open cmd.exe from a service. My operating system is Windows 8. Is it possible from a Windows service or is there another alternative to this.

(I want to open cmd.exe after some interval - that’s why I chose the Windows service)

+4
source share
1 answer

This will not work. The problem is that you are trying to show the interface (console) from a Windows service, and the Windows service is not working in the context of any particular user. Starting with Vista and later, Windows Services runs in an isolated session and is prohibited from interacting with the user or the desktop, making it impossible to start.

, , .

  • , cmd , Windows, .
  • cmd.exe, , , ,

cmd :

ProcessStartInfo processInfo = new ProcessStartInfo
            {
                WindowStyle = ProcessWindowStyle.Normal,
                CreateNoWindow = true,
                UseShellExecute = false,
                FileName = "cmd.exe",
                Arguments = @"/C copy /b Image1.jpg + Archive.rar Image2.jpg"
            };

, , :

+1

Source: https://habr.com/ru/post/1618371/


All Articles