I seem to be experiencing a DLL import error only when the following powershell command is executed from the run dialog. The exact same command from an open powershell window executes without an issue.
Error producing RUN dialog command:
Powershell $k=Add-Type -MemberDefinition '[DllImport("user32.dll")]public static extern bool ShowWindow(IntPtr h, int n);' -Name w -PassThru
The following error is printed:
No errors are returned when running the same code in an already open powershell window:
$k=Add-Type -MemberDefinition '[DllImport("user32.dll")]public static extern bool ShowWindow(IntPtr h, int n);' -Name w
-PassThru;
I find this beyond confusing as i am under the impression both methods should have produced the same outcome. Is there any logical reasoning to why this is happening? How can this error be resolved?
The purpose of the code is to minimize the powershell window. I am aware that there are other methods to achieve this.