Reputation: 103761
I have no idea if this is even a programming question, or something that is configured through my OS. But how would I get it so my console application uses Powershell instead of cmd? I know I can open Powershell and run the program from there, but even then, calls such as system("Get-Childitem")
fail.
I'm using Visual C++ by the way, if that matters. But if it's a compiler specific thing, then I would also like to know how to do it with GCC.
Upvotes: 3
Views: 1366
Reputation: 3587
Look into the environment variable COMSPEC, which on Windows, and DOS 1.1 before that, controls which shell is utilized for launching programs that need a shell.
SET COMSPEC=%path_to_powershell%
You can do the same within your C++ program by calling the setenv
C runtime call;
Upvotes: 6