How to Implement ShelExec in Your CI/CD Pipeline
This guide shows a practical, secure way to integrate ShelExec (a small utility that calls the Windows ShellExecute/ShellExecuteEx API from the command line) into a CI/CD pipeline to run files, URLs, or shell-registered actions on Windows build/runner agents.
Assumptions
- Your CI runners are Windows-based (self-hosted or cloud Windows agents).
- You have ShelExec.exe available (download or build from Naughter Software source).
- You want controlled, auditable invocation (avoid interactive prompts and privileged escalation where possible).
1) Obtain and verify ShelExec
- Download ShelExec.exe (e.g., from the project site or a trusted repo) or build from source.
- Verify checksum/signature and scan with your standard malware scanner.
- Place ShelExec.exe in a secured artifact repository or include it in your repo under a tools/ directory (prefer repository rules that prevent modification).
2) Prepare a runner environment
- Ensure the Windows runner user has only necessary permissions. Avoid using Administrator unless required.
- If ShelExec must launch GUI apps, use interactive sessions only on dedicated agents. Prefer non-interactive command-line targets for CI.
- Add tools/ to PATH on the runner or reference the full path to ShelExec.exe in scripts.
3) Scripted invocation patterns
Use ShelExec to open files/URLs or run an associated app without knowing exact executable name.
Examples (PowerShell):
- Basic: run a file or URL
powershell
# Runs the associated application for index.html or opens URL & “C:\agents\tools\ShelExec.exe” “C:\build\output\index.html” & “C:\agents\tools\ShelExec.exe” “https://example.com/deploy”
- Specify an EXE and params (from ShelExec options)
powershell
& “C:\agents\tools\ShelExec.exe” /EXE “C:\Program Files\MyPlayer\mplayer2.exe” ”/PARAMS:/play C:\media\file.mid”
- Wait for launched process to exit (use /WAIT when available)
powershell
& “C:\agents\tools\ShelExec.exe” ”/PARAMS:/play C:\media\file.mid” /WAIT /EXE “mplayer2.exe” \(exitCode</span><span> = </span><span class="token" style="color: rgb(54, 172, 170);">\)LASTEXITCODE if (\(exitCode</span><span> </span><span class="token" style="color: rgb(57, 58, 52);">-ne</span><span> 0</span><span class="token" style="color: rgb(57, 58, 52);">)</span><span> </span><span class="token" style="color: rgb(57, 58, 52);">{</span><span> </span><span class="token" style="color: rgb(0, 0, 255);">throw</span><span> </span><span class="token" style="color: rgb(163, 21, 21);">"ShelExec returned </span><span class="token" style="color: rgb(54, 172, 170);">\)exitCode“ }
(Adjust paths/flags to the ShelExec version you use.)
4) Integrate into CI job stages
- Build stage: use ShelExec only if build step requires invoking a registered helper app (rare).
- Test stage: avoid GUI launches; prefer headless test tools. If you must run a registered test runner via ShelExec, run on dedicated Windows test agents.
- Deploy stage: use ShelExec for deployment steps that open installer/registration files or call system-registered handlers,
Leave a Reply