Hsilgos / nppsaveasadmin

Plugin for notepad++ to save as administrator. "Offical" fork of https://sourceforge.net/projects/nppsaveasadmin/
31 stars 6 forks source link

NPPSaveAsAdmin isn't working anymore with Notepad 8.1.6 and later #33

Closed dodmi closed 2 years ago

dodmi commented 2 years ago

Hi, I just encountered a problem, that NPPSaveAsAdmin isn't working anymore on latest Notepad++. I had to downgrade to Notepad++ 8.1.5 (32bit). With later versions, UAC isn't triggered anymore on saving a file.

I guess, the root cause is the change in the file saving api in version 8.1.6: https://notepad-plus-plus.org/news/v816-released/

Can you please provide a fix?

Hsilgos commented 2 years ago

Hi. I was sure that they gonna add embedded feature in NPP, especially after I broke NPP with https://github.com/Hsilgos/nppsaveasadmin/issues/24 I'll have a look int new API, thanks for reporting

dodmi commented 2 years ago

That would be really kind. Thank you.

Hsilgos commented 2 years ago

@dodmi , I tried to reproduce and failed. I have:

I tried both x64 and x86 versions. Please describe your setup.

Also I checked changes in Notepad++ which you mentioned and they look compatible with plugin.

dodmi commented 2 years ago

Well, that's strange. Actually I just realized, it seems to work in general, but not with the hosts file. I have

Trying to change 'C:\Program Files (x86)\Notepad++\change.log' for example raises 'NppAdminAccess.exe' as expected with both Notepad++ 8.1.5 and 8.2. Trying to change 'C:\Windows\sysnative\drivers\etc\hosts' works with Notepad++ 8.1.5 but triggers the default Notepad++ behavior in later versions (also in 8.2). This seems to be not working for all files accessed via 'C:\Windows\sysnative\'. Please note, that sysnative is a special virtual path, which is provided on x64 systems to allow x86 applications to access files in 'C:\Windows\system32' as default calls to 'C:\Windows\system32' are redirected to 'C:\Windows\SysWOW64'.

dodmi commented 2 years ago

@Hsilgos Were you able to reproduce the issue or do you need more information?

Hsilgos commented 2 years ago

@dodmi , yes, I understand the issue... But this scenario doesn't work for me in Npp at all... Here is my steps:

  1. Open hosts with following command:

    Notepad++ C:\Windows\sysnative\drivers\etc\hosts

  2. Try to save it. I see default dialog "This file cannot be saved... Do you want to run launch Notepad++ in administrative move?". I press "Yes"
  3. Notepad++ is relaunching and I try again to save. This time I got error "Please check whether if this file is opened in another program

I try with x86 Notepad++ 8.2 and 8.2.1 on x64 Win10 Pro.

Can you confirm that Notepad++ works for you in the same scenario? (I'll be very surprised because I didn't find requered calls to Wow64EnableWow64FsRedirection() / Wow64DisableWow64FsRedirection() ) in the Npp code during the save...

dodmi commented 2 years ago

@Hsilgos Ok, actually I didn't try to save the file after Notepad++ reopened as admin (as all changes were lost). I upgraded again to test and can confirm, the behavior is exactly the same here. Trying to save hosts file, when Notepad++ is running as admin will trigger another error, that the file couldn't be saved. I can also confirm, that it is working flawlessly with Notepad++ 8.1.5 x86 and NppSaveAsAdmin, as I used this setup to make the changes (and older versions).

So is this a Notepad++ issue and you can't do anything about it?

Hsilgos commented 2 years ago

@dodmi , well... I may try to kind of "fix" the issue directly in my plugin... But actually it must be reported to Notepad++. Report the issue in their repo, may be I'll have a look at it and will try to fix it in Notepad++ if no one takes care of it :)

dodmi commented 2 years ago

I've opened an issue at Notepad++: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/11196

dodmi commented 2 years ago

The issue was fixed in Notepad++, so I'm closing this issue. Thank you for your help.

ArtClark commented 2 months ago

Couldn't save a simple txt file to C:\Program Files (x86)\delete.txt then prompted to save in Documents instead. Sorry it doesn't work anymore. :( v8.6.3 64bit Version: 1.0.211