vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Allow user-level installations

Open anrichter opened this issue 11 years ago • 38 comments

When i installed Visual Studio Code as an Administrator and log in with another account afterwards, the "Open with Code" Explorer entries (in the context menu of Files and Folders) are gone.

I searched for it in the Windows Registry and it seems to me, that the Windows Setup only add the entries for the current user. In my example only for the Administrator account of my computer which is another one than that i worked with normally.

It would be nice when the Visual Studio Code setup add the "Open with Code" capability to any user of the system.

Thanks & Greetings, Andreas

anrichter avatar Nov 24 '15 08:11 anrichter

The Open with Code action is gone by default since 0.8.0. Code now registers itself as an editor and you can and should associate it with file extensions, like you would do any other application. If you manually install Code again, the installer will ask you if you still want the context menu actions, but you must install it as the user that you want the actions for.

joaomoreno avatar Nov 24 '15 09:11 joaomoreno

Thanks for your reply.

Assign vscode with specified file extensions like .md works ok. But i can't set the association for folders to open a complete folder in vscode from within the explorer.

And unfortunately my working user account, which should use the actions, does not have adequate rights to install any programm on my computer (AD policy). So i can't select the options in setup for my working user.

Do you have any suggestion how i can add the context menu item manually? In regedit.exe?

tia, Andreas

anrichter avatar Nov 24 '15 10:11 anrichter

Here's what we do in the installer, hope it's not too cryptic.

Root: HKCU; Subkey: "SOFTWARE\Classes\*\shell\VSCode"; ValueType: expandsz; ValueName: ""; ValueData: "Open with Code"; Tasks: addcontextmenufiles; Flags: uninsdeletekey
Root: HKCU; Subkey: "SOFTWARE\Classes\*\shell\VSCode"; ValueType: expandsz; ValueName: "Icon"; ValueData: "{app}\Code.exe"; Tasks: addcontextmenufiles
Root: HKCU; Subkey: "SOFTWARE\Classes\*\shell\VSCode\command"; ValueType: expandsz; ValueName: ""; ValueData: """{app}\Code.exe"" ""%1"""; Tasks: addcontextmenufiles

Root: HKCU; Subkey: "SOFTWARE\Classes\directory\shell\VSCode"; ValueType: expandsz; ValueName: ""; ValueData: "Open with Code"; Tasks: addcontextmenufolders; Flags: uninsdeletekey
Root: HKCU; Subkey: "SOFTWARE\Classes\directory\shell\VSCode"; ValueType: expandsz; ValueName: "Icon"; ValueData: "{app}\Code.exe"; Tasks: addcontextmenufolders
Root: HKCU; Subkey: "SOFTWARE\Classes\directory\shell\VSCode\command"; ValueType: expandsz; ValueName: ""; ValueData: """{app}\Code.exe"" ""%V"""; Tasks: addcontextmenufolders

Root: HKCU; Subkey: "SOFTWARE\Classes\directory\background\shell\VSCode"; ValueType: expandsz; ValueName: ""; ValueData: "Open with Code"; Tasks: addcontextmenufolders; Flags: uninsdeletekey
Root: HKCU; Subkey: "SOFTWARE\Classes\directory\background\shell\VSCode"; ValueType: expandsz; ValueName: "Icon"; ValueData: "{app}\Code.exe"; Tasks: addcontextmenufolders
Root: HKCU; Subkey: "SOFTWARE\Classes\directory\background\shell\VSCode\command"; ValueType: expandsz; ValueName: ""; ValueData: """{app}\Code.exe"" ""%V"""; Tasks: addcontextmenufolders

I will actually reopen this and rename it according to the real issue.

joaomoreno avatar Nov 24 '15 10:11 joaomoreno

Thanks. That helped. :+1:

anrichter avatar Nov 24 '15 12:11 anrichter

+1.

I don't have Administrator access on my machine and I don't understand why I would need it in order to install a text editor. Please support the ability to install Code without requiring elevated permissions.

I'm not sure if this request matches the original description of this issue, but it matches the current title...

jchadwick avatar Feb 02 '16 19:02 jchadwick

@joaomoreno you changed the title of the issue which now matches exactly my (and @jchadwick) request, but missmatches the authors request.

Disappearing context menus because of different user-level installations are not related to "allow installations in different user-levels" or: I want to install VS Code without admin privilegs.

GodLesZ avatar Apr 20 '16 09:04 GodLesZ

They do not disappear. They are configured in the registry under HKCU, meaning they are scoped under the user who ran the installation. Had the installer been able to be run per user, independently, you'd have these actions in any user you'd like.

There always the possibility of adding some commands to Code that would install and uninstall these shortcuts for your user, as commands in the command palette.. That might actually be a good idea. What do you think?

joaomoreno avatar Apr 20 '16 09:04 joaomoreno

I'd be all for a command being added to configure this for the current user. Though I have to wonder why you don't just provide an option for installing the context menu to all users and then sticking the registry settings in the HKLM hive. Running a system as a non-admin should be what we are all doing these days right?

I converted the registry keys posted by @joaomoreno above into a PowerShell script. Only the script will install the keys at HKLM so it will work for all users on the system. If you only want the context menu for the current user then just change the $regHive variable to 'HKCU:'

## Configure Open with VSCode Context Menu ##

# Get CPU architecture and configure VSCode location
$isOSx64 = (Get-WmiObject -Class Win32_ComputerSystem).SystemType -match '(x64)'
$programFiles = If ($isOSx64) { "%PROGRAMFILES(X86)%" } Else { "%PROGRAMFILES%" }
$vscodeLoc = [Environment]::ExpandEnvironmentVariables($programFiles) + '\Microsoft VS Code\Code.exe'
$regHive = 'HKLM:'   # Change this to 'HKCU:' if you only want this for your current user

# Configure Open with VSCode for files
New-Item -Path "$regHive\SOFTWARE\Classes\*\shell\VSCode"
Set-ItemProperty -LiteralPath "$regHive\SOFTWARE\Classes\*\shell\VSCode" -Name '(Default)' -Type ExpandString -Value 'Open with VSCode'
Set-ItemProperty -LiteralPath "$regHive\SOFTWARE\Classes\*\shell\VSCode" -Name 'Icon' -Type ExpandString -Value "$vscodeLoc"
New-Item -Path "$regHive\SOFTWARE\Classes\*\shell\VSCode\command"
Set-ItemProperty -LiteralPath "$regHive\SOFTWARE\Classes\*\shell\VSCode\command" -Name '(Default)' -Type ExpandString -Value "`"$vscodeLoc`" `"%1`""

# Configure Open with VSCode for Directories
New-Item -Path "$regHive\SOFTWARE\Classes\directory\shell\VSCode"
Set-ItemProperty -LiteralPath "$regHive\SOFTWARE\Classes\directory\shell\VSCode" -Name '(Default)' -Type ExpandString -Value 'Open with VSCode'
Set-ItemProperty -LiteralPath "$regHive\SOFTWARE\Classes\directory\shell\VSCode" -Name 'Icon' -Type ExpandString -Value "$vscodeLoc"
New-Item -Path "$regHive\SOFTWARE\Classes\directory\shell\VSCode\command"
Set-ItemProperty -LiteralPath "$regHive\SOFTWARE\Classes\directory\shell\VSCode\command" -Name '(Default)' -Type ExpandString -Value "`"$vscodeLoc`" `"%V`""

# Configure Open with VSCode for Directories while inside the directory (right-click on empty space)
New-Item -Path "$regHive\SOFTWARE\Classes\directory\background\shell\VSCode"
Set-ItemProperty -LiteralPath "$regHive\SOFTWARE\Classes\directory\background\shell\VSCode" -Name '(Default)' -Type ExpandString -Value 'Open with VSCode'
Set-ItemProperty -LiteralPath "$regHive\SOFTWARE\Classes\directory\background\shell\VSCode" -Name 'Icon' -Type ExpandString -Value "$vscodeLoc"
New-Item -Path "$regHive\SOFTWARE\Classes\directory\background\shell\VSCode\command"
Set-ItemProperty -LiteralPath "$regHive\SOFTWARE\Classes\directory\background\shell\VSCode\command" -Name '(Default)' -Type ExpandString -Value "`"$vscodeLoc`" `"%V`""

The-New-Guy avatar May 09 '16 15:05 The-New-Guy

Hi,

for me both variants are ok. When install VSCode for all users on the machine as an administrator, the HKLM should be written. When install VSCode in user scope for the logged in user without admin-rights, the HKCU should be written.

I think, that's a good way.

Greetings, Andreas

anrichter avatar May 11 '16 08:05 anrichter

Looks like there's a workaround:

https://github.com/Microsoft/vscode/wiki/How-to-Contribute#build-and-run-from-source

Quite an ugly one, of course.

mihailik avatar May 17 '16 11:05 mihailik

@mihailik open source builds lack some of the features of the official builds (extensions, auto updating).

Tyriar avatar May 17 '16 17:05 Tyriar

@Tyriar and as I've found out, you can't build behind the proxy -- electron-retrieving scripts don't honour npm nor git proxy settings.

mihailik avatar May 18 '16 06:05 mihailik

Hi, is this a problem of electron packager ?

hmica avatar May 20 '16 09:05 hmica

I can confirm that the installer is still not writing the relevant keys at HKLM.

chkpnt avatar Jul 05 '16 21:07 chkpnt

Hope this can be fixed soon. No one in our organization run under admin account as default, so it is not possible for us to install vs-code with these "Open in code" shell extensions. To install it we right click and select "run as administrator", but then it adds it only to the administrator account, which we don't use.

rgullhaug avatar Jan 11 '17 11:01 rgullhaug

I don't think it is that hard to do, in fact Atom does this by default. Every time VSCode updates I need to download the zip again, which is annoying...

JimAmuro avatar Mar 31 '17 13:03 JimAmuro

This is a must. (Unless anyone has ideas for some sort of enterprise update strategy?)

Tuckie avatar Apr 18 '17 12:04 Tuckie

+1

kralla avatar May 02 '17 19:05 kralla

Would it be possible to adopt the same publishing / deployment / updating process as MS Teams? It also uses Electron but allows automatic updates without admin rights being required.

Edit: Looks like they use Squirrel with the built-in auto updater functionality https://github.com/electron/electron/blob/master/docs/api/auto-updater.md

Tiberriver256 avatar May 19 '17 01:05 Tiberriver256

+1. Any update on this?

saad749 avatar May 31 '17 05:05 saad749