'Run powershell scripts from a C program

I'm creating a C program to run several powershell scripts. But when I run the command with the system function it opens the script in a txt file instead of running the script.

Example: system("C:\Scripts\script.ps1"); Example: system(".\script.ps1");

I also tried but it shows the error -> & was not expected at this time: system(& 'C:\Scripts\script.ps1');

Someone who can help me to run the script from the system function of the C language?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source