Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attach to process tries to use Wmic on Windows 11 machine without it #13137

Open
johnfc-soulassembly opened this issue Jan 9, 2025 · 1 comment

Comments

@johnfc-soulassembly
Copy link

Environment

  • OS and version: Windows 11 Pro Version 10.0.26100 Build 26100
  • VS Code: Version 1.96.2
  • C/C++ extension: 1.22.11

Cannot attach to remote executable with debugger, get this : Image

Bug Summary and Steps to Reproduce

Bug Summary:

Steps to reproduce:
1> Add attachment configuration to launch.json
2> Attempt to attach
3> Fail

Debugger Configurations

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(Windows) Attach",
            "type": "cppvsdbg",
            "request": "attach",
            "processId" : "${command:pickProcess}",
            "logging": { "engineLogging": true, "trace": true, "traceResponse": true }
        },
        {
            // Use IntelliSense to find out which attributes exist for C# debugging
            // Use hover for the description of the existing attributes
            // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md
            "name": ".NET Core Launch (console)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            // If you have changed target frameworks, make sure to update the program path.
            "program": "${workspaceFolder}/Engine/Binaries/DotNET/UnrealBuildTool/UnrealBuildTool.dll",
            "args": [],
            "cwd": "${workspaceFolder}/Engine/Source/Programs/UnrealBuildTool",
            // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
            "console": "internalConsole",
            "stopAtEntry": false
        },
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach"
        }
    ]
}

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/UE5.sln",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary;ForceNoAlign"
            ],
            "problemMatcher": "$msCompile"
        },
        {
            "label": "publish",
            "command": "dotnet",
            "type": "process",
            "args": [
                "publish",
                "${workspaceFolder}/UE5.sln",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary;ForceNoAlign"
            ],
            "problemMatcher": "$msCompile"
        },
        {
            "label": "watch",
            "command": "dotnet",
            "type": "process",
            "args": [
                "watch",
                "run",
                "--project",
                "${workspaceFolder}/UE5.sln"
            ],
            "problemMatcher": "$msCompile"
        }
    ]
}

Debugger Logs

intelliSenseEngine is disabled

Other Extensions

ClangD
OculusDebugger
Perforce
C#
Python
Pylance
PythonDebugger
UnrealEnginePython

Additional Information

No response

@fearthecowboy
Copy link
Member

Very Strange.

I see that WMIC is indeed deprecated quite a while back, and they must be removing it from very new builds of windows.

Hmm. It should only be falling back to using wmic if it can't find PowerShell (either powershell.exe or pwsh.exe)

Ah, I see where it's going wrong. Yeah, that's a bug.

If you are brave, and want to see if you can make a quick fix and unblock that, you can attempt the following.

open the file C:\Users\[YOURUSERNAME]\.vscode\extensions\ms-vscode.cpptools-1.22.11-win32-x64\dist\src\main.js

and replace the findPowerShell() function (around line 88628) with the following and then restart vscode see if that fixes it quickly. (Back up the main.js file first!)

The function is incorrectly returning on the first time it throws, and it really shouldn't be.

function findPowerShell() {
    const dirs = (process.env.PATH || '').replace(/"+/g, '').split(';').filter(x => x);
    const exts = (process.env.PATHEXT || '').split(';');
    const names = ['pwsh', 'powershell'];
    for (const name of names) {
        const candidates = dirs.reduce((paths, dir) => [
            ...paths, ...exts.map(ext => path.join(dir, name + ext))
        ], []);
        for (const candidate of candidates) {
            try {
                if (fs.statSync(candidate).isFile()) {
                    return name;
                }
            }
            catch (e) {
                // ignore, continue (should not actually return here) 
            }
        }
    }
}

that should unblock you - if you can test that and it works, I'll put the fix in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

3 participants