After upgrading my VS Code to version 1.79.1 it is throwing error when I am trying to launch in admin mode. Without admin mode launch is working. Adding the screenshot of the error and the version details below.

The window terminated unexpectedly (reason:'launch-failed',code:'18')

Googling "github vscode issues windows administrator code 18", I found this issue ticket: Can't run as Administrator - launch-failed code 18
#185057, where a maintainer said:
Please refer to https://code.visualstudio.com/docs/setup/windows#_unable-to-run-as-admin-when-applocker-is-enabled for launching as administrator.
Currently
--no-sandboxdoes not work as expected which is being resolved in #184687 and fix will be available in 1.79.2.
From the linked user documentation:
With the introduction of process sandboxing (discussed in this blog post) running as administrator is currently unsupported when AppLocker is configured due to a limitation of the runtime sandbox. If your work requires that you run VS Code from an elevated terminal, you can launch
codewith--no-sandbox --disable-gpu-sandboxas a workaround.Subscribe to issue #122951 to receive updates.
Until VS Code 1.79.2 is released, you can try using VS Code Insiders with --no-sandbox --disable-gpu-sandbox.
Apparently updating to 1.79.2 has not fixed this issue for several users. I am still watching the issue ticket and will update this answer as the situation evolves.
Note that in VS Code 1.80, there is a new flag, --disable-chromium-sandbox, that can be used in the place of --no-sandbox --disable-gpu-sandbox, and some other related features that you might be interested in. It can also be placed in argv.json (run Preferences: Configure Runtime Arguments in the command palette to open argv.json).
The workaround I found on version 1.81.1 with a system-wide install is the following.
code --no-sandbox --disable-gpu-sandboxIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With