0

I want to create an application that recursively displays the subdirectories and files starting from a root directory. There are some directories / subdirectories that cannot be accessed by administrator account. When starting the application, I want it to receive system rights in order to display the whole directory tree. How can I achieve this?

squirrel
  • 1
  • 1
  • 1
  • You can't do this without running as a service. See https://stackoverflow.com/questions/34194996/run-exe-as-system-account – Matthew Watson Jul 30 '20 at 17:41
  • take a look at psexec.exe -i -s – jjj Jul 30 '20 at 17:52
  • The application has a GUI based on the FileDialog. When running as system using psexec.exe, I cannot choose directories like Desktop, Downloads or Documents as root directory, but I can choose C:\Windows as root directory. When choosing Desktop or Downloads or Documents I get the "directory is unavailable" error. Why? – squirrel Jul 31 '20 at 22:24
  • @MatthewWatson Since my app has a GUI (it's a Windows Forms App) I didn't find any possibility to run it as a service. The solution would be to create the service (I have done this tutorial: https://docs.microsoft.com/en-us/dotnet/framework/windows-services/walkthrough-creating-a-windows-service-application-in-the-component-designer) and the Windows Forms App separately, but I don't know how to connect them. I have read about WCF and IPC, but I have no idea how this could be done. Is there any possibility to run Windows Forms App as a service? How could communicate the service and the Form? – squirrel Jul 31 '20 at 22:39

0 Answers0