I want to run a powershell command from c (gcc) and I was told to use the
system()
Invoke-Item
To run PowerShell commands using system()
function, you need to do something like this:
system("powershell -Command \"<your-command-here>\"");
AFAIK, the default shell on Windows is Command Prompt. PowerShell is another shell and you need to invoke it first to run commands in it.
Example (run dir
command):
Using Command Prompt:
> PowerShell.exe -Command "dir"
Using Linux Terminal:
$ powershell -Command "dir"
So, the above command format should work for your case also i.e.:
system("PowerShell.exe -Command \"Invoke-Item ...\"");