Launching PowerShell using the Win32 API
November 29, 2016 1 minute read
I was working on a personal project in C on Windows when I stumbled upon a really strange roadblock: a PowerShell instance would not actually run the script given to it when started via Windows API but it would when launched manually from a
Eventually the realisation came to me: PowerShell doesn't like the
DETACHED_PROCESS option for
CreateProcess(). I have no idea what it was doing with it there, but it didn't involve actually working.
I changed it to
CREATE_NO_WINDOW and all is fine in the world.