Home > Mobile >  How to execute C:\...\executable commands in terminal?
How to execute C:\...\executable commands in terminal?

Time:12-08

Question

I'm trying to execute a command with the format {C:\...\executable} build {C:\...\executable} link. Here is the specific example I'm trying to execute. All it does is install a golang module which lets me debug in vs code.

C:\Program Files\Go\bin\go.exe build -o C:\Users\linds\go\bin\dlv-dap.exe github.com/go-delve/delve/cmd/dlv

The issue i'm having is that I don't know how to actually execute it. I've tried running it in powershell and bash but both come back and say that I cant run program with the form C:\....

How do I execute code with the following or similar formats?

~~

Sorry that my descriptions of the issue aren't the best because frankly I hardly know what I'm dealing with right here. I can clarify more if needed.

CodePudding user response:

Press Windows-R and then type cmd, then press ENTER. This will open a Windows terminal, you can execute your command there.

Edit: Thinking about it, you would probably need an Administrator console. In case the above does not work, find the entry "Command Prompt" in your start menu, right-click on it and press "Run as administrator".

CodePudding user response:

Since you're trying to invoke an executable whose path contains spaces, you must quote the path in order for a shell to recognize it as a single argument.

  • From PowerShell:
& 'C:\Program Files\Go\bin\go.exe' build -o C:\Users\linds\go\bin\dlv-dap.exe github.com/go-delve/delve/cmd/dlv

Note: &, the call operator, isn't always needed, but is needed whenever a command path is quoted and/or contains variable references - see this answer for details.

  • From cmd.exe:
"C:\Program Files\Go\bin\go.exe" build -o C:\Users\linds\go\bin\dlv-dap.exe github.com/go-delve/delve/cmd/dlv
  • Related