“Copy Code” adds a right-click option to Windows Explorer that places any file’s
contents on your clipboard wrapped in a Markdown-ready fenced code block—perfect
for chats, issues, docs, or pull requests with syntax highlighting.
-
After installation, you can right click a file, e.g.
hello.pyand select "Copy Code". This will copy it in this format:hello.py (C:\Projects\hello.py) ```python print("Hello, world!") ```
If Explorer launches a raw PowerShell script from a context menu, Windows
always flashes a console window—even with -WindowStyle Hidden.
Compiling the script with PS2EXE turns it into a tiny Win32 executable that
runs in the “windows” subsystem (no console), so Copy Code pops up nothing
at all—just instant clipboard magic.
Inside C:\Program Files (or any sub-folder)
That protected path prevents non-admin users or malware from swapping out the executable that Explorer will run.
-
Open Windows Terminal / Powershell as Administrator
-
Clone the repo into the protected path
git clone https://github.com/zappybiby/RightClickCopyCode.git "C:\Program Files\CopyCode"
-
Change into the install directory
cd "C:\Program Files\CopyCode" -
Bypass the execution policy (if needed)
This lets you run the unsigned installer script for this session only:Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
-
Run the installer
.\Install.ps1 -Install- Compiles
CopyCode.ps1→CopyCode.exe - Registers the Copy code context-menu entry
- Prompts to install PS2EXE if it’s not already available
- Compiles
- Right-click any file in Explorer.
- Choose Copy code.
- Paste anywhere—your clipboard now holds a labelled, fenced block.
Use the built-in switch:
.\Install.ps1 -Uninstall