1

I have a PC with Windows IOT Enterprise and would like to control (turn on or off and set exclusions) the UWF from my C# application. I tried to access the uwfmgr.exe with System.Diagnostics.Process. I tried two approaches and they differ in the init of filename and arguments:

  1. System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo("cmd", /C c:\\windows\\system32\\uwfmgr get-config");
  2. System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo("c:\\windows\\system32\\uwfmgr.exe", "get-config");

The remaining code is the same and posted below:

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/C c:\\windows\\system32\\uwfmgr get-config");
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.CreateNoWindow = true;

startInfo.UserName = "Test";
var s = new System.Security.SecureString();
s.AppendChar('T');
s.AppendChar('e');
s.AppendChar('s');
s.AppendChar('t');
startInfo.Password = s;

process.StartInfo = startInfo;
process.Start();

result = "";
result_error = "";
exc = "";

process.WaitForExit();
result = process.StandardOutput.ReadToEnd();
result_error = process.StandardError.ReadToEnd();

Console.WriteLine(result);
File.WriteAllText("test.txt", result);

The user "Test" is another user with admin rights. The result is still that the command is aborted (access refused). I tried to use my logged in user which is an admin too but it does not make a difference.

I tried to start my exe as admin as well and get the same result.

Is there any solution for that right problem? Can I start the Unified Write Filter as admin?

dbc
  • 104,963
  • 20
  • 228
  • 340
Nelf
  • 19
  • 5
  • A bit late but maybe my program written in C# will help you or others to activate and deactivate the UWF. https://github.com/cregx/uwf-dashboard – creg Sep 20 '21 at 14:44

1 Answers1

-1

This could be a 32/64 bit issue. Try to call it via the path c:\windows\sysnative\uwfmgr.exe which will redirect correctly depending on your applications architecture.

On a sidenode: Besides calling uwfmgr via the executable directly, there is a way to access it via WMI which will also give you easier parseable output. See this question for some C# sample code: How to get registry and file exclusions from UWF using WMI query in C#

clamp
  • 33,000
  • 75
  • 203
  • 299