0

A service launches an exe program successfully using this code:

using (Process myProcess = new Process()) {

      myProcess.StartInfo.WorkingDirectory = processFolderPath;
      myProcess.StartInfo.FileName = "PROCESS_1.exe";
      myProcess.StartInfo.CreateNoWindow = false;
      myProcess.Start();
   }

From PROCESS_1, I'd like to open a folder:

Process.Start(@"C:\Users\mainuser\Documents\folder_to_open");

This works if the PROCESS_1 is started normally by double clicking the exe or as admin. But it fails to open a folder, if PROCESS_1 is started from service and is running as SYSTEM.

Is it possible to open a folder in explorer if the process trying to open a folder is run as SYSTEM from a Service?

mxmissile
  • 11,464
  • 3
  • 53
  • 79
Robert Segdewick
  • 543
  • 5
  • 17
  • A service does not by default have access to the user's session. See duplicate for a possible work-around. Keeping in mind that in general, it's a really poor practice to have a service doing any sort of GUI presentation at all. You should prefer a program a user explicitly runs for managing that sort of thing. – Peter Duniho Nov 03 '20 at 22:37
  • Services are (for good reasons) typically not allowed to interact with the desktop. Same probably applies to processes started by a service. Especially opening new windows from the service seems a bad idea because that will interfere with the users current work. And what happens, if there is no user logged on, but the service is of course still running? – derpirscher Nov 03 '20 at 22:41

0 Answers0