Repository navigation
Conversation
This circumvents the group policy which restricts apps writing to the registry, which is what reg.exe does despite it's best intentions. We can't fix that here, so instead we're going to use the PowerShell API for interacting with the registry, which has it's own quirks. Because everything is terrible.
7f12cfe to
5f39cff
Compare
Could we use something which accesses the native APIs directly? Like https://www.npmjs.com/package/windows-registry ? |
|
Yeah we've had a couple of reports of problems with not being allowed access to reg.exe but we use it to setup our shell integration on launch from the installer/updater as well as in the settings view where you can toggle the various integration options. That windows registry npm package does look useful though. My experience with doing crazy shell tricks to work around issues tells me whatever you come up with will be flakey between OS versions. (We do a powershell trick for --wait and it's been a crazy ride) |
@niik this is a good shout. I'm not sure why I avoided it when I was initially looking at our registry support - maybe because the API was rather raw? I'll give it a shot and see if it's faster than the PS approach. EDIT: I think it was the lack of type declarations that meant I skipped over it at the time EDIT 2: arggggh native module isn't getting pulled in by webpack: EDIT 3: testing it outside of Desktop suggests that it doesn't support enumerating the range of values - we can workaround this, but then it's more code. I also had a minor PR that's still not been merged, so getting additional work incorporated seems unlikely in the short term: CatalystCode/windows-registry-node#52 |
|
@shiftkey huge ups for even doing this heavy lifting investigative work. Thank you thank you thank you! |
begoldsm
left a comment
There was a problem hiding this comment.
Out of curiosity, is it possible to do the registry read check one time (during initial install) and then save the values that are important to the app in AppData? That way you can require elevation once (during initial setup) and then retrieve the info from your local app data for every subsequent launch. That would get around the performance issue here and wouldn't require a reliance on PowerShell.
This sounds like a good idea, but how would it handle installing or uninstalling supported editors? |
|
@j-f1 that is a good question. There could, perhaps, be an explicit option to "add/remove" an editor which could require elevation when it does it's check? I am not familiar with all the surface area where GitDesktop reads from the registry. |
This doesn't cover the ability for users to add and remove items, as @j-f1 mentioned. The app refreshes it's list of editors and shells on each launch but will defer it until you do something with the app (like open the Options view). That won't cover everyone (for example, if you an install an editor after checking your options and noticing it's not there), but keeps the code simple enough.
I'd rather not make this something that requires manual work by the users, let alone all the work to manage elevation correctly.
Here's the current list:
|
|
@shiftkey ah that makes sense. Then yeah, I am not sure if there is a better way in windows to read from the registry when this group policy exists :( |
You could fork the repo and |
|
@j-f1 after spending a bunch of time with |
|
Can you let me know when you've packaged that up? Would be nice to get
Atom off of the command-line wrapper as it often fails in schools and work
environments as reg.exe is locked down.
…On Fri, Nov 17, 2017 at 2:09 PM Brendan Forster ***@***.***> wrote:
@j-f1 <https://github.com/j-f1> after spending a bunch of time with
windows-registry-node I don't think it's worth trying to mash in here.
I've got some simple native code which I'll package up once it's working
correctly and use that instead.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3209 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAHQpzqeh4Z8VKEaz_b89vjoSjbBNmQyks5s3gQfgaJpZM4QNpOI>
.
|
|
@damieng sure thing - I only currently need |
|
Alright, I went back to the drawing board and have a working registry API that's pure C++. The start is desktop/registry-js#9 and I'll open a PR to migrate us over to this new library once it does what we need it to do. |



Fixes #3105
Fixes #3123
Strap yourselves in folks, it's time for a story.
Group Policy is a thing which lets administrators lock down their Windows machines. And here's the group policy for stopping apps from writing to the registry:
In theory,
reg.exeshouldn't need to write the registry when you doREG QUERY [key]but here we are:And we can't fix
reg.exeso I'm all:And I start looking at alternatives. I really want to not use PowerShell here but it turns out we're already doing something very similar in
squirrel-updater.ts:powershell.exe- so we assume it's already installeddesktop/app/src/main-process/squirrel-updater.ts
Lines 160 to 171 in 24d46fa
desktop/app/src/main-process/squirrel-updater.ts
Lines 173 to 187 in 24d46fa
desktop/app/src/main-process/squirrel-updater.ts
Lines 189 to 191 in 24d46fa
Fiiine, let's do this. This means I avoid the worries about active code pages from before.
reg.exeapproachOut-Stringthe result to ensure it's formatted nicely for parsing