Why Does Drag-and-Drop Fail in Admin VS Code?
Drag-and-drop fails because VS Code is running as administrator and File Explorer isn't. Windows' User Interface Privilege Isolation (UIPI) stops a normal app from sending input or drop data to an elevated window, so the drop is silently refused. The fix is to run VS Code normally and elevate only the commands that need it, with sudo on Windows 11 24H2 or later, gsudo, or a separate admin terminal. If VS Code has to stay elevated, open files with Ctrl+O and a pasted path; ordinary copy and paste still works.
Check whether VS Code is running as administrator
- The title bar: on Windows, VS Code adds [Administrator] to the window title when it's elevated.
- The integrated terminal: it runs at the same level as VS Code. Run
whoami /groups | findstr /i "Mandatory"; High Mandatory Level means elevated, Medium Mandatory Level means normal. - The shortcut: if VS Code is always elevated, right-click its shortcut, choose Properties > Compatibility, and check whether Run this program as an administrator is ticked.
Why Windows blocks the drop
Windows gives every process an integrity level. Apps you start normally run at medium integrity; apps you start with Run as administrator run at high. UIPI stops a lower-level process from sending window messages and simulated input to a higher-level one, which protects elevated apps from being driven by anything else on the desktop. Microsoft's troubleshooting guidance puts it plainly: an application "can only send commands to applications of the same or lower elevation."
File Explorer runs at medium integrity, so a file dragged from it can't be dropped onto an elevated VS Code window. The same applies to any normal app you drag from, including browsers and clipboard managers. Why you can't drag into an admin window covers the mechanism for every app, not just VS Code.
The fix: run VS Code normally and elevate single commands
Most of the time VS Code itself doesn't need admin rights; one command does. Keep the editor at normal level and elevate just that command.
Sudo for Windows (Windows 11, version 24H2 or later)
- Open Settings > System > Advanced.
- Turn Enable sudo on.
- In VS Code's terminal, put
sudoin front of the command that needs elevation, for examplesudo netstat -ab, and approve the UAC prompt.
By default (In a new window), the elevated command opens in its own console window. The Input closed and Inline modes run it in the current window, and Microsoft's documentation explains the security trade-offs of each.
gsudo
On older Windows versions, gsudo gives you a similar sudo command. Install it with winget install gerardog.gsudo, restart the terminal, then run gsudo your-command.
A separate admin terminal
Keep one Windows Terminal window open as administrator for the tasks that need it, and do everything else in a normal VS Code window.
If a shortcut forces elevation, clear Run this program as an administrator on its Compatibility tab so VS Code starts normally.
If VS Code has to stay elevated
Some jobs, such as editing files under C:\Program Files or debugging a process that runs elevated, are easier from an elevated editor. These still work:
- Open with a pasted path. In Explorer, select the file and press Ctrl+Shift+C to copy its path. In VS Code, press Ctrl+O and paste it into the file name box. How to copy a file path that works in the terminal covers quoting for every shell.
- Open from the integrated terminal.
code -r .\src\app.tsopens the file in the last active window, which is the elevated one you're typing in. - Use File > Open Folder for a whole project instead of dropping the folder on the window.
- Copy and paste text normally. Ctrl+C in a normal app and Ctrl+V in elevated VS Code works; it's dragging and simulated input that UIPI blocks. When drag-and-drop is the wrong choice lists other cases where paste beats dragging.
Avoid fixes that start File Explorer or other tools as administrator just to make dragging work. That removes the separation UAC exists to provide.
Clipboard managers and drag shelves hit the same wall
A clipboard manager running at normal level faces the same rules as Explorer. Edge Drop's drag-out is a standard Windows drag, so it can't drop into elevated VS Code either. Its click-to-paste sends Ctrl+V to the window you were using, which is the kind of simulated input UIPI blocks for an elevated window. What does work is the card's Copy button: it only places the item on the clipboard, and you then press Ctrl+V in the elevated window yourself. How to drag an item out of Edge Drop covers where drag-out does work.
FAQ
Does copy and paste work in VS Code running as administrator?
Yes. Copying in a normal app and pasting into elevated VS Code with Ctrl+V works. Drag-and-drop and tools that paste by simulating keystrokes are what fail.
Is there a VS Code setting that allows drops while elevated?
No. The block comes from Windows, not VS Code, so the reliable fix is not running the editor elevated.
Does this affect VS Code Remote SSH or WSL windows?
The same rule applies to the local VS Code window: if it runs as administrator, drops from Explorer fail. Does VS Code Remote SSH share your local clipboard? covers how copy and paste behave in remote windows.
Related reading
- Can't Drag and Drop Into an Admin Window? Here's Why
- How to Copy a File Path That Works in the Terminal
- Does VS Code Remote SSH Share Your Local Clipboard?
- How to Drag Files and Images Out of Edge Drop
Sources
- UIPI issues with UI and browser automation actions (Microsoft Learn) — UIPI blocks interaction with elevated apps; the Compatibility tab setting.
- Mandatory Integrity Control (Microsoft Learn) — standard users get medium integrity, elevated users high.
- How User Account Control works (Microsoft Learn) — integrity levels and elevation.
- DoDragDrop (Microsoft Learn) — the OLE drag-and-drop call a drag source makes.
- Sudo for Windows (Microsoft Learn) — Windows 11 24H2 requirement, Enable sudo, and the three modes.
- gsudo (GitHub) —
winget install gerardog.gsudo. - Command Line Interface (VS Code docs) —
code -ropens in the last active window. - windowTitle.ts (VS Code source, GitHub) — the [Administrator] title suffix on Windows.
Deepender Yadav created Edge Drop and builds and tests it, from the edge-hover shelf to each release. A B.Tech Computer Science Engineering student, Deepender writes the Edge Drop guides, comparisons and developer posts, and checks product details against the app's source code.
GitHub · LinkedInCopy. Stack. Drop.
Transform your clipboard into an interactive edge shelf. Stack, pin, and drag assets into any app with zero friction.
Download for Windows Get from Microsoft Store
How to Install Guide · First 10 Minutes Guide · Drag & Drop Guide · Edge Drop vs Win+V · Support
Free · Lightweight · Privacy First