Setting up a Root Session in VSCode using Command Prompt

What will you learn?

Discover how to establish a root session in Visual Studio Code by configuring it with command prompt commands for elevated access.

Introduction to the Problem and Solution

When tackling tasks that demand elevated permissions on your system, starting a root session in VSCode becomes essential. By modifying settings to run the editor as an administrator, you can seamlessly execute administrative tasks directly within VSCode.

The solution involves tweaking the shortcut used to launch Visual Studio Code and integrating specific command prompt directives. Once implemented, you’ll have the ability to open a root session effortlessly whenever needed.


# Open Command Prompt as Administrator and navigate to the folder containing 'code.cmd'
cd C:\Users\YourUsername\AppData\Local\Programs\Microsoft VS Code\bin

# Execute 'code.cmd' with '--user-data-dir' parameter set to store user data in a separate location for escalated access
.\code.cmd --user-data-dir="C:/VSCodeRootSession"

# Visual Studio Code will now run with administrative privileges enabled for advanced operations.

# Copyright PHD



  1. Opening Command Prompt: Utilize the cd command to navigate to the directory housing ‘code.cmd’.
  2. Executing code.cmd: Run ‘code.cmd’ with additional parameters like ‘–user-data-dir’ to create a separate user data directory for elevated access.
  3. Running as Administrator: Launching Visual Studio Code through this method grants administrative privileges for various system-level tasks.
    How can I revert back from running VSCode as an administrator?

    To revert, simply close Visual Studio Code and relaunch it without using the modified shortcut or commands.

    Can I customize other settings while launching as admin?

    Yes, you can further configure startup options by exploring additional command line arguments compatible with VSCode.

    Will my extensions work in this mode?

    Extensions should function correctly; exercise caution when dealing with extensions closely interacting with system files or configurations.

    Is there any security risk associated with enabling root sessions?

    Running applications as an administrator poses potential security threats if not handled carefully; avoid unnecessary elevated access whenever possible.

    Can I automate this process for convenience?

    Creating scripts or shortcuts can streamline opening VSCode in root mode whenever needed efficiently.


    In conclusion, initiating a root session within Visual Studio Code empowers users to perform complex actions seamlessly without compromising system integrity. Always exercise caution while utilizing administrative privileges and leverage these capabilities judiciously based on operational needs.

    Leave a Comment