如何以管理员身份在 VS Code 中调试程序

发布于 2025-01-10 22:49:06 字数 209 浏览 0 评论 0原文

我正在使用 Tracy 来调试 C++ 代码,但如果程序不以管理员身份运行,它的许多功能都会受到限制。我正在使用 VS Code 进行调试,并且希望不必使用不同的调试器来执行此操作。我尝试以管理员身份启动 VS Code 并进行调试,但它没有改变任何内容。

由于 VS Code 的不幸命名,每当我尝试查找如何执行此操作时,我只会得到如何使用 Visual Studio 执行此操作的结果。

I'm using Tracy to debug C++ code, but a lot of its features are restricted if the program isn't run as administrator. I'm debugging with VS Code and would like not to have to use a different debugger to do this. I've tried starting VS Code as an admin and debugging but it didn't change anything.

With VS Code's unfortunate naming, anytime I try to lookup how to do this I just get results for how to do it with Visual Studio.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蛮可爱 2025-01-17 22:49:06

您可以在 VS Code 上安装代码运行器扩展
你可以在这张图片中看到它

you can install the code runner extension on vs code
you can see it in this picture

蔚蓝源自深海 2025-01-17 22:49:06

在 VS Code 中以管理员身份运行 C++ 程序的步骤:

Run VS Code as Administrator:
    Close VS Code.
    Right-click the VS Code icon and select "Run as administrator."

Modify launch.json:
    Open the .vscode/launch.json file.
    Ensure your configuration includes:

    json

    {
      "version": "0.2.0",
      "configurations": [
        {
          "name": "Launch Program",
          "type": "cppdbg",
          "request": "launch",
          "program": "${workspaceFolder}/your_program.exe",
          "args": [],
          "stopAtEntry": false,
          "cwd": "${workspaceFolder}",
          "externalConsole": true
        }
      ]
    }

Run Your Debug Session:
    Start debugging (F5). The program should now run with admin privileges.

确保您正在调试的程序也已正确设置。如果问题仍然存在,请检查您的用户帐户是否具有必要的权限。

Steps to run your C++ program as an administrator in VS Code:

Run VS Code as Administrator:
    Close VS Code.
    Right-click the VS Code icon and select "Run as administrator."

Modify launch.json:
    Open the .vscode/launch.json file.
    Ensure your configuration includes:

    json

    {
      "version": "0.2.0",
      "configurations": [
        {
          "name": "Launch Program",
          "type": "cppdbg",
          "request": "launch",
          "program": "${workspaceFolder}/your_program.exe",
          "args": [],
          "stopAtEntry": false,
          "cwd": "${workspaceFolder}",
          "externalConsole": true
        }
      ]
    }

Run Your Debug Session:
    Start debugging (F5). The program should now run with admin privileges.

Make sure that the program you are debugging is also set up correctly. If issues persist, check if your user account has the necessary permissions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文