samedi 6 février 2021

Cannot run powershell script via `system` function. Is this a unique case?

I have a function which calls a powershell script. The function seems to work pretty good for other stuff but it seems to fail when i run it on a specific script. One reason I think it fails is because when the script is doing work it displays a banner on powershell showing its progress. Could that be a reason? This is the command

std::string str = "powershell -executionPolicy bypass process -file C:\\xxx\\VolumeCreate.ps1 "
        "-driveModel \"xxxxx\" | Select-String -Pattern \"output:\" > \"c:\\dot.txt\"";
    int status = system(str.c_str());

this is what it looks like in PowerShell

enter image description here

Any suggestions on why it might be failing ? Happy to provide more details if needed

Aucun commentaire:

Enregistrer un commentaire