vscode-code-runner
vscode-code-runner copied to clipboard
Cannot run .exe files
Here is a part of my settings.json
"code-runner.executorMapByFileExtension": {
".vb": "cd $dir && vbc /nologo $fileName && $dir$fileNameWithoutExt",
".vbs": "cscript //Nologo",
".scala": "scala",
".jl": "julia",
".cr": "crystal",
".ml": "ocaml",
".exs": "elixir",
".hx": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
".rkt": "racket",
".ahk": "autohotkey",
".au3": "autoit3",
".kt": "cd $dir && kotlinc $fileName -include-runtime -d $fileNameWithoutExt.jar && java -jar $fileNameWithoutExt.jar",
".kts": "kotlinc -script",
".dart": "dart",
".pas": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
".pp": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
".d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
".hs": "runhaskell",
".nim": "nim compile --verbosity:0 --hints:off --run",
".csproj": "dotnet run --project",
".fsproj": "dotnet run --project",
".exe": "cd $dir && $fileName"
}
But when I right click on an .exe an click run code, nothing happens. What am I doing wrong ?
OS: Windows 10 64-bit VS Code: Version 1.25
Did you see anything as below? You may want to open VS Code as admin
No I didn't see anything like that
And it doesn't work even if I run it as administrator.
What if you run other types of code?
.cpp works and .py also works
code-runner.executorMapByFileExtension
does not work but all programming languages work
Could you have a screenshot of your settings?
{
"git.ignoreMissingGitWarning": true,
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
"code-runner.executorMap": {
"javascript": "node",
"java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
"c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"cpp": "cd $dir && \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\Common7\\Tools\\VsDevCmd.bat\" && cl.exe /EHsc /W3 /std:c++latest \"$fileName\" && del \"$fileNameWithoutExt.obj\" && cls && \"$fileNameWithoutExt.exe\"",
"objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"php": "php",
"python": "cd $dir && python \"$fileName\"",
"perl": "perl",
"perl6": "perl6",
"ruby": "ruby",
"go": "go run",
"lua": "lua",
"groovy": "groovy",
"powershell": "powershell -ExecutionPolicy ByPass -File",
"bat": "cmd /c",
"shellscript": "bash",
"fsharp": "fsi",
"csharp": "scriptcs",
"vbscript": "cscript //Nologo",
"typescript": "ts-node",
"coffeescript": "coffee",
"scala": "scala",
"swift": "swift",
"julia": "julia",
"crystal": "crystal",
"ocaml": "ocaml",
"r": "Rscript",
"applescript": "osascript",
"clojure": "lein exec",
"haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
"rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
"racket": "racket",
"ahk": "autohotkey",
"autoit": "autoit3",
"dart": "dart",
"pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
"d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
"haskell": "runhaskell",
"nim": "nim compile --verbosity:0 --hints:off --run",
"executable": "cd $dir && $fileName"
},
"code-runner.runInTerminal": true,
"code-runner.saveFileBeforeRun": true,
"C_Cpp.clang_format_style": "VIsual Studio",
"C_Cpp.loggingLevel": "Error",
"python.autoComplete.addBrackets": true,
"python.globalModuleInstallation": true,
"editor.cursorStyle": "line",
"editor.dragAndDrop": false,
"editor.emptySelectionClipboard": false,
"editor.fontFamily": "'Hasklig', Consolas, monospace",
"editor.fontLigatures": true,
"editor.fontSize": 16,
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.smoothScrolling": true,
"terminal.integrated.rightClickBehavior": "default",
"macros": {
"inline": [
"jupyter.runSelectionLine",
"cursorDown"
]
},
"git.autofetch": false,
"git.autoRepositoryDetection": false,
"git.autorefresh": false,
"git.enabled": false,
"workbench.colorTheme": "Adapta Nokto",
"files.autoGuessEncoding": true,
"window.zoomLevel": 0,
"media.player": {
"players": [
{
"name": "My VLC player",
"type": "vlc",
}
]
},
"C_Cpp.clang_format_path": "clang-format",
"C_Cpp.default.intelliSenseMode": "msvc-x64",
"C_Cpp.default.cStandard": "c11",
"C_Cpp.default.cppStandard": "c++14",
"code-runner.executorMapByFileExtension": {
".vb": "cd $dir && vbc /nologo $fileName && $dir$fileNameWithoutExt",
".vbs": "cscript //Nologo",
".scala": "scala",
".jl": "julia",
".cr": "crystal",
".ml": "ocaml",
".exs": "elixir",
".hx": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
".rkt": "racket",
".ahk": "autohotkey",
".au3": "autoit3",
".kt": "cd $dir && kotlinc $fileName -include-runtime -d $fileNameWithoutExt.jar && java -jar $fileNameWithoutExt.jar",
".kts": "kotlinc -script",
".dart": "dart",
".pas": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
".pp": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
".d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
".hs": "runhaskell",
".nim": "nim compile --verbosity:0 --hints:off --run",
".csproj": "dotnet run --project",
".fsproj": "dotnet run --project",
".exe": "cd $dir && $fileName"
},
"files.associations": {
".exe": "executable"
}
}
This is the settings.json
What if you run .csproj
file?
How do I do that ?
Just create a abcd.csproj
file with any content, then Run Code
Ok. I will do that in some time. Thanks for your help.
Yes it works
Could you remove below setting and try again?
"files.associations": {
".exe": "executable"
}
And when you run .exe
, nothing in Output Channel? And could you see any error in Help
->Toggle Developer Tools
->Console
?
After I remove the setting the same thing happens.
I see nothing in the Output Channel
Here is what I see in Developer Tools Console:
ERR cannot open file:///c%3A/Users/prash/Documents/Salil/Programming/Programs/C%2B%2B/Exercises/Chapter%203/Ex%2011.exe. Detail: File seems to be binary and cannot be opened as text: Error: cannot open file:///c%3A/Users/prash/Documents/Salil/Programming/Programs/C%2B%2B/Exercises/Chapter%203/Ex%2011.exe. Detail: File seems to be binary and cannot be opened as text
at file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:4150:832
at Object.v [as _notify] (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:151:375)
at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:154:592)
at n.Class.derive._creator._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
at n.Class.derive._creator._chainedError (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:255)
at n (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:153:115)
at n.Class.define.cancel.then (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:156:736)
at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:153:184)
at n.Class.derive._creator._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
at n.Class.derive._creator._setCompleteValue (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:590)
at Object.v [as _notify] (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:151:357)
at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:154:592)
at n.Class.derive._creator._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
at n.Class.derive._creator._chainedError (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:255)
at n (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:153:115)
at n.Class.define.cancel.then (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:156:736)
at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:153:184)
at n.Class.derive._creator._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
at n.Class.derive._creator._setCompleteValue (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:590)
at Object.v [as _notify] (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:151:357)
at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:154:592)
at n.Class.derive._creator._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
at n.Class.derive._creator._chainedError (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:255)
at n (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:153:115)
at n.Class.define.cancel.then (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:156:736)
at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:153:184)
at n.Class.derive._creator._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
at n.Class.derive._creator._setCompleteValue (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:590)
at Object.v [as _notify] (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:151:357)
at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:154:592)
at n.Class.derive._creator._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
at n.Class.derive._creator._chainedError (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:255)
at n (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:153:115)
at n.Class.define.cancel.then (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:156:736)
at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:153:184)
at n.Class.derive._creator._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
at n.Class.derive._creator._setCompleteValue (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:590)
at Object.v [as _notify] (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:151:357)
at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:154:592)
at n.Class.derive._creator._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
at n.Class.derive._creator._chainedError (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:255)
at n (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:153:115)
at n.Class.define.cancel.then (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:156:736)
at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:153:184)
at n.Class.derive._creator._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
at n.Class.derive._creator._setCompleteValue (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:590)
at Object.v [as _notify] (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:151:357)
at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:154:592)
at n.Class.derive._oncancel._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
at n.Class.derive._oncancel._error (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:413)
at l (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:158:962)
at file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:159:70
at Object.v [as _notify] (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:151:375)
at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:154:592)
at n.Class.derive._oncancel._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
at n.Class.derive._oncancel._error (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:413)
at v (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:3174:344)
at file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:3175:224
at n.Class.define.cancel.then (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:157:366)
at file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:3175:172
at callback (C:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\graceful-fs\polyfills.js:128:19)
at FSReqWrap.wrapper [as oncomplete] (original-fs.js:629:17)
Did you find a solution ?
Oh, I could repro this issue now. This is a bug. I will take a look at this.
Thank You
When will it be corrected ? Is there a alternative currently ?
You could use "code-runner.customCommand" as workaround
How do I use that because when I tried it, even that was not working
"code-runner.customCommand": "foo/bar/abc.exe"
what does foo/bar/abc.exe mean ? I want it for any exe file with any name
In that case, there is no good workaround.
Ok when will the bug be repaired
and what exactly does the error message mean ?
The funny thing is that it used to work 3 months earlier!
Seems VS Code has API change, .exe would not be opened by default now. If you open a .exe file as a text, then you could run it.
How do I open .exe as a text ?