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

VSCode installer "open with..." fails on unprivileged accounts #33785

Closed
lethevimlet opened this issue Sep 4, 2017 · 7 comments
Closed

VSCode installer "open with..." fails on unprivileged accounts #33785

lethevimlet opened this issue Sep 4, 2017 · 7 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug windows VS Code on Windows issues wont-fix workbench-os-integration Native OS integration issues
Milestone

Comments

@lethevimlet
Copy link

lethevimlet commented Sep 4, 2017

VSCode Windows installer fails to add context menu on standard user accounts since it uses HKEY_ROOT

Installer reg values should use HKEY_CURRENT_USER\Software\Classes instead of HKEY_ROOT, this will fix the issue and work for all kind of users.

This fixes issue #12147 which was closed prematurely.

As a meanwhile solution:

Add this to a text file and rename it to .reg, then double click on it and enjoy open with VSCode.
(Note: this will only work on default install location, you must edit paths if another install location is used)


Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\*\shell\VSCode]
C:\Program Files\Microsoft VS Code\Code.exe

[HKEY_CURRENT_USER\Software\Classes\*\shell\VSCode\command]
"C:\Program Files\Microsoft VS Code\Code.exe" "%1"

[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\VSCode]
C:\Program Files\Microsoft VS Code\Code.exe

[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\VSCode\command]
"C:\Program Files\Microsoft VS Code\Code.exe" "%V"

[HKEY_CURRENT_USER\Software\Classes\Directory\shell\VSCode]
C:\Program Files\Microsoft VS Code\Code.exe

[HKEY_CURRENT_USER\Software\Classes\Directory\shell\VSCode\command]
"C:\Program Files\Microsoft VS Code\Code.exe" "%V"

@joaomoreno joaomoreno added this to the September 2017 milestone Sep 5, 2017
@joaomoreno joaomoreno added bug Issue identified by VS Code Team member as probable bug windows VS Code on Windows issues labels Sep 5, 2017
@dblatner
Copy link

Your Solution works perfectly when VS Code is installed on the default location. I'm using the 64-bit version. Thank you @lethevimlet !

@lethevimlet
Copy link
Author

The hex values are the path to the default location just change them if you need a different location, I'm glad it helps someone ^_^

@JimAmuro
Copy link

I think the installer does use HKEY_CURRENT_USER\Software\Classes, because according to MSDN:

To change the default settings, store the changes under HKEY_LOCAL_MACHINE\Software\Classes. If you write keys to a key under HKEY_CLASSES_ROOT, the system stores the information under HKEY_LOCAL_MACHINE\Software\Classes.

If it writes to ROOT, the default settings should apply to non-admin too, which is not the case.
Hence it writes to CURRENT_USER of the admin who gives the priviledge for that non-admin.

@balefrost
Copy link

From looking at build/win32/code.iss, it looks like these are explicitly added to HKEY_CURRENT_USER, and this matches what I've seen in the registry itself. I actually wonder why they're not being added to HKEY_LOCAL_MACHINE. These registry keys seem like they would apply to all users on the system.

@lethevimlet
Copy link
Author

As this is still unresolved, I updated the question in order to change the hex values to strings so it can be easily used by people using a non default install path, didn't test it though but it should work, let me know if I doesn't.

@am11
Copy link

am11 commented Dec 11, 2018

Based on this discussion, I was able to create file and folder context menu association with VScode portable:

:: File Name - RegisterVSCodePortable.bat
:: File Location - D:\Software\Editor\VSCodePortable.1.29.1  (roaming directory)

SET CodeExePath=D:\Software\Editor\VSCodePortable.1.29.1\Code.exe

REG ADD HKCU\Software\Classes\*\shell\VSCode\command /t REG_EXPAND_SZ /d "\"%CodeExePath%\" \"%%1\""
REG ADD HKCU\Software\Classes\Directory\Background\shell\VSCode\command /t REG_EXPAND_SZ /d "\"%CodeExePath%\" \"%%V\""
REG ADD HKCU\Software\Classes\Folder\shell\VSCode\command /t REG_EXPAND_SZ /d "\"%CodeExePath%\" \"%%V\""

(could also be a workaround for #57198)

@joaomoreno joaomoreno added the workbench-os-integration Native OS integration issues label Oct 14, 2019
@hemanth-n-govindan
Copy link

this worked for me, Awesome!!

#12147 (comment)

Thanks a lot @lethevimlet

@github-actions github-actions bot locked and limited conversation to collaborators Dec 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug windows VS Code on Windows issues wont-fix workbench-os-integration Native OS integration issues
Projects
None yet
Development

No branches or pull requests

8 participants
@joaomoreno @balefrost @lethevimlet @dblatner @am11 @JimAmuro @hemanth-n-govindan and others