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

Allow user-level installations #534

Closed
anrichter opened this issue Nov 24, 2015 · 38 comments
Closed

Allow user-level installations #534

anrichter opened this issue Nov 24, 2015 · 38 comments
Assignees
Labels
feature-request Request for new features or functionality install-update VS Code installation and upgrade system issues on-testplan windows VS Code on Windows issues
Milestone

Comments

@anrichter
Copy link

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

@joaomoreno
Copy link
Member

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.

@anrichter
Copy link
Author

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

@joaomoreno
Copy link
Member

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 joaomoreno reopened this Nov 24, 2015
@joaomoreno joaomoreno changed the title Missing "Open with Code" in Windows Explorer after Install Allow user-level installations Nov 24, 2015
@anrichter
Copy link
Author

Thanks. That helped. 👍

@joaomoreno joaomoreno added the feature-request Request for new features or functionality label Nov 25, 2015
@egamma egamma modified the milestone: Backlog Dec 10, 2015
@joaomoreno joaomoreno removed their assignment Jan 6, 2016
@jchadwick
Copy link
Contributor

+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...

@GodLesZ
Copy link

GodLesZ commented Apr 20, 2016

@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.

@joaomoreno
Copy link
Member

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?

@The-New-Guy
Copy link

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`""

@anrichter
Copy link
Author

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

@mihailik
Copy link
Contributor

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.

@Tyriar
Copy link
Member

Tyriar commented May 17, 2016

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

@mihailik
Copy link
Contributor

@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.

@hmica
Copy link

hmica commented May 20, 2016

Hi,
is this a problem of electron packager ?

@chkpnt
Copy link

chkpnt commented Jul 5, 2016

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

@rgullhaug
Copy link

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.

@gabriellima
Copy link

Anyone tracking this issue? What's the rank on roadmap? Admin access in corporative desktops is almost extinct theses days.

If the barrier is only about HLKM vs HKLU keys, please just ask it during installation wizard: All users / User-only.

It's boring having to update manually.

@samal-rasmussen
Copy link

My office just removed everybody's admin rights for improved security they say. So now I can't update VS Code without bothering support. This adds significant friction to my use of VS Code.

@Tiberriver256
Copy link

Would PrivilegesRequired=lowest option work for this?

http://www.jrsoftware.org/ishelp/index.php?topic=setup_privilegesrequired

@jdobner
Copy link

jdobner commented Apr 12, 2018

Without this, vscode is really difficult to use in a locked-down environment. I think this is critical

@tdgleason
Copy link

Not having the "Open with Code" in the context menu of files/folders for explorer and the "code" command in powershell/console is awful!

My company gave me a domain account that I use for development...I can install software on my machine with the local machine admin account.

The Vscode install installs the contextmenus/etc under the local machine admin account only. No matter how you try. Open as admin/blahblah

I need a clean way of installing the reg keys. And I didn't find anything on the net that i can trust.

Make it a post install command or something

Otherwise I'm drawn to Sublime Text

@The-New-Guy
Copy link

@tdgleason If all you are trying to do is get the registry keys set, this issue itself has those registry keys listed. @joaomoreno, a member of the Microsoft org (i.e. someone you can trust in this context), listed the register keys needed at the top of this issue. I later took that and created some powershell commands to do that for you and posted them above. I've been using that for every install I use and haven't had an issue. It would be nice to get this feature added instead of having to run those commands each time, but since that happens fairly infrequently anyways I just added it to my workstation build process.

@TiemenSch
Copy link

TiemenSch commented Apr 23, 2018

@The-New-Guy I tried applying your commands to my installation at work (stuck on Windows 7) and they didn't work out of the box for HKCU (cannot confirm HKLM). I had to change some capitalization before it worked as well as adding some keys (not the values) manually using regedit. After that, it worked like a charm, though.

Changed them to:

## Configure Open with VSCode Context Menu ##

# Get CPU architecture and configure VSCode location
$isOSx64 = (Get-WmiObject -Class Win32_ComputerSystem).SystemType -match '(x64)'
$vscodeLoc = 'ENTER PATH HERE'
$regHive = 'HKCU:'   # Change this to 'HKLM:' if you only want this for all users.

# 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`""

@ankostis
Copy link

ankostis commented Apr 23, 2018

There is a SO question about this blocker issue: https://stackoverflow.com/questions/43467756/vs-code-extension-installation-without-admin-rights

According to Abdullah Leghari's response:

You have the option to unpack the zip file and use the editor without running the installer.
You will lack some features like 'Open with Code' in the contextmenu of the file explorer.

@samal-rasmussen
Copy link

A link to the vs code zip file: https://code.visualstudio.com/docs/?dv=winzip

@TiemenSch
Copy link

I saw in the milestone that this was deferred, @joaomoreno. Do you need help? Testing or other problems holding you back?

@joaomoreno joaomoreno modified the milestones: Backlog, May 2018 Apr 26, 2018
@joaomoreno
Copy link
Member

@TiemenSch Thanks for asking. No real problems now that we've made a decision on what path to follow. We will provide two separate Setup packages. The current one, as well as one which requires no admin privileges. It's just postponed to next month.

@joaomoreno joaomoreno self-assigned this Apr 26, 2018
@TiemenSch
Copy link

OK! Good to hear that there's discussions/work behind the scenes. You're going to please a lot of people!

@joaomoreno joaomoreno modified the milestones: May 2018, June 2018 May 29, 2018
@joaomoreno
Copy link
Member

This was merged to master and will come out this June release.

https://twitter.com/joaomoreno/status/1011184822570582017

@nejsimon
Copy link

nejsimon commented Jul 23, 2018


Disregard that, I found out when reading the release details.

@wahidshafique
Copy link
Contributor

@nejsimon what did you find out, for posterity? I've had the same issue.

@nejsimon
Copy link

@wahidshafique The release notes says that it's not included in the june release because they want more feedback, so you'd still have to use the insider build.

https://code.visualstudio.com/updates/v1_25#_user-setup-for-windows

@vscodebot vscodebot bot locked and limited conversation to collaborators Aug 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality install-update VS Code installation and upgrade system issues on-testplan windows VS Code on Windows issues
Projects
None yet
Development

No branches or pull requests