-1

I am trying to run a cmd command from a react native windows - UWP application that shutdowm the computer. There is any way to do it???

I have created a c# native module which creates a process that run the cmd command. Getting "access is denied" allways

1 Answers1

0

You can't run a cmd command directly from the UWP app. UWP apps are running in the sandbox. What you could do is to create an .exe file which runs the command. Then put the .exe file in the UWP package and launch the .exe file from the UWP app by calling FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync(). Here are the steps:

  1. Create a .exe file which could run your command.
  2. Add the .exe file into your project in Visual Studio like the Assets folder.
  3. Modify the mainifest file of the UWP app to add the runFullTrust capability.
  4. Call FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync API to launch the .exe file.

You could refer to Arya's answer here: Run an exe/batch file from UWP app. Some other documents related:FullTrustProcessLauncher Class

Roy Li - MSFT
  • 8,043
  • 1
  • 7
  • 13