i want to execute this commands from c#:
@echo off
PowerShell "ForEach($v in (Get-Command -Name \"Set-ProcessMitigation\").Parameters[\"Disable\"].Attributes.ValidValues){Set-ProcessMitigation -System -Disable $v.ToString() -ErrorAction SilentlyContinue}"
pause
i put the it in cmd file and run it using :
Process.Start(CMDFilePath);
but error occurre:
C:\Users\New-hwid\Desktop\Debug2>PowerShell "ForEach($v in (Get-Command -Name \"Set-ProcessMitigation\").Parameters[\"Disable\"].Attributes.ValidValues){Set-ProcessMitigation -System -Disable $v.ToString() -ErrorAction SilentlyContinue}"
Get-Command : The term 'Set-ProcessMitigation' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:16
+ ForEach($v in (Get-Command -Name "Set-ProcessMitigation").Parameters[ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-ProcessMitigation:String) [Get-Command], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand
Cannot index into a null array.
At line:1 char:15
+ ... rEach($v in (Get-Command -Name "Set-ProcessMitigation").Parameters["D ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
when i open cmd file normally it worked fine , but when i run it via Process.Start(...) this error happen, my OS is windows 10 64 bit, how to run CMD file without error? Thanks