maya
maya

Reputation: 25

Permission denied when I try to open VSCode using a command line

I'm trying to edit a file by openning it via git using VS Code as an editor

$code texte.txt

and I got this

/c/Users/MAYA/AppData/Local/Programs/Microsoft VS Code/bin/code: line 61: /c/Users/MAYA/AppData/Local/Programs/Microsoft VS Code/Code.exe: Permission denied

I google it but didn' find anything usefull, any help please?

P.S: my environement: windows 7, MINGW64

Upvotes: 1

Views: 11284

Answers (4)

TrueEddie
TrueEddie

Reputation: 2233

I was attempting to run the command from the Git Bash window on Windows when I got this error. I simply right-clicked the Git Bash icon and and chose "Run as administrator". After that I had no problem running the command.

Upvotes: 0

Chris McDonald
Chris McDonald

Reputation: 103

Thought it would be useful to share this as well.

WSL is not able to run VS Code with Windows environment administrator permissions.

  1. Right-click on your Visual Studio Code shortcut and select "Properties" in C:\Users\<myUsername>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Visual Studio Code

  2. In the Compatibility tab's settings section un-check "Run this program as an administrator"

A wonderful person brought this up on this Reddit post.

Upvotes: 1

maya
maya

Reputation: 25

I added the path from the Explorer's breadcrumb to Environment Variables under Advanced System Setting then I used $code.cmd file.extension

Upvotes: 0

maya
maya

Reputation: 25

Follow the steps below and be proud of the OS you use.

  1. Search for "Advanced System Setting" from Start.
  2. Click on Environment Variables
  3. On System Variables choose "path" from Variable tab and click on Edit.
  4. Click on New on the right side of the popup window.
  5. Copy your path from the Explorer's breadcrumb path and paste it into the new opened path in step 4, example:- C:\Program Files\Microsoft VS Code\bin
  6. Click Ok on all the open windows to confirm changes and restart your cmd
  7. Now you run it $code.cmd file.extension

Upvotes: 0

Related Questions