0

I want to run power shell command on a simple console app.

I'm running on x64 platform.

As I'm running with AnyCpu option it's not working.

I'm getting error pnputil : The term 'pnputil' is not recognized as the name of a cmdlet,

If i'm running with x64 option it's working.

How can I run the application so it'll work on platforms(e.g on x32 , x64)

Without specifying manually?

Thank You.

Edit:

I can solve it with something like this. but don't want as it's not safe.

K.W
  • 123
  • 7
  • I found that when you set the "Any CPU" platform, also try unchecking the "Prefer 32-bit" option in Project Properties window. Is helping on x64 but not sure about x32 – K.W May 12 '22 at 09:15
  • You're trying to circumvent filesystem redirection, so why not disable file system redirection? What exactly do you mean by "as it's not safe"? – Mathias R. Jessen May 12 '22 at 09:32
  • Microsoft documentation: Note This value is for system use only. To avoid unpredictable behavior, do not modify this value in any way. https://learn.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-wow64disablewow64fsredirection – K.W May 12 '22 at 09:59
  • 1
    That's not about the function itself, it's telling you not to modify the _output value from the function call_ - so just _don't do that_ and you're good :) – Mathias R. Jessen May 12 '22 at 10:06
  • 1
    Terminology: not all C# implementations are on systems with Powershell. e.g. C# on a Linux system won't have it. Sounds like you mean "CPU architecture" for a Windows application. That's not what I'd assume from the word "all platforms". But maybe that's standard terminology in the C# world, IDK. – Peter Cordes May 12 '22 at 13:52

0 Answers0