No Shell

win32 API

Create Processes
  • CreateProcessW

File Association
  • Use ShellExecuteEx  or ShellExecuteW , to open files by association (e.g., foo.pdf  with Acrobat).

  • CreateProcess  does not handle file associations.

UAC Elevation
  • CreateProcessW  runs with the caller’s token. It will not trigger UAC elevation.

  • To elevate use ShellExecuteEx  with runas  or use CreateProcessWithTokenW  / CreateProcessAsUser  with the right token.

"Conveniences" you lose by not using a shell
  • Built-ins :

    • Will not run dir , cd , or other cmd.exe  built-ins. Those are implemented inside the shell.

  • .bat / .ps1 files :

    • *.bat , *.cmd , .ps1  are not native executables.

    • *.bat  must be run by cmd.exe cmd.exe /c yourscript.bat  (or use the shell).

    • *.ps1  must be run by PowerShell (or invoked via pwsh -File ).

  • Pipes :

    • This refers to the usage of something like:

      • >

        • cmd.exe: Redirect stdout to a file (overwrite).

        • powershell: Redirect stdout to a file (overwrite).

      • |

        • cmd.exe: byte-stream pipe.

        • powershell: object pipeline.

    • You must create pipes yourself and wire STARTUPINFO.hStdInput / hStdOutput  and bInheritHandles .

    • You control the environment block and current directory. If you want inherited handles or specific stdio redirection you must set those in STARTUPINFO  and use bInheritHandles .

    • Odin does this with the win32  api by:

    &win32.STARTUPINFOW{
        cb = size_of(win32.STARTUPINFOW),
        hStdError Β = stderr_handle,
        hStdOutput = stdout_handle,
        hStdInput Β = stdin_handle,
        dwFlags = win32.STARTF_USESTDHANDLES,
    },
    
  • Conditionals :

    • This refers to the usage of something like:

      • ||

        • cmd.exe: run RHS if LHS fails.

        • powershell: run RHS if LHS fails.

      • &&

        • cmd.exe: run RHS if LHS success.

        • powershell: run RHS if LHS success.

    • Parent or shell must implement conditional logic. Parent must check exit code and decide.

  • Sequence invoke :

    • This refers to the usage of something like:

      • &

        • cmd.exe: Command operator. Runs next command unconditionally.

      • ;

        • powershell: Command operator.

    • If you want sequencing invoke multiple CreateProcessW  calls or implement sequencing logic in your program.