Hi,
I am new to NSIS but have a legacy script that causes a blue screen on Windows 10. The issue is caused by a call to
DeleteRegKey HKLM "($NONEXISTINGVAR)".
The definition of $NONEXISTINGVAR was commented out, some time ago, so in effect the script is trying to delete a key that does not exist. I would expect that it would do nothing however it deletes the HKEY_LOCAL_MACHINE\BCD00000000\Description entry and thus the blue screen on reboot.
This issue did not occur with the same script in windows 8. Any ideas as to why this happens or if it is bug would be appreciated.
Thanks
DeleteRegKey Blue Screen issue
14 posts
BTW. Warning Do not try DeleteRegKey HKLM "($NONEXISTINGVAR)".
unless you have a windows recovery disk available.
unless you have a windows recovery disk available.
NSIS version?
I can see how it could happen if the path was "" but you have () there so it should never be a empty path, strange.
I can see how it could happen if the path was "" but you have () there so it should never be a empty path, strange.
It happens in the latest version as well as in version 2.3. I am away from my pc so I might have got the () incorrect. Is the empty string a bug then?
Thanks
Thanks
2.3 or 3.2? There has been some changes to the registry handling after 3.0 but from my quick look at the code I don't think they matter even if it was related to registry delete handling. 2.3 is way too old, at least use 2.5x.
I don't know if a empty string is a bug, you are basically asking it to delete the entire tree. If we should allow you to do that is another question.
I don't know if a empty string is a bug, you are basically asking it to delete the entire tree. If we should allow you to do that is another question.
Hi Anders,
Thanks for your replies. I am can now give you the actual revision details.
The issue is in both v2.44 and v3.02.
The entire tree does not get deleted just the Description Folder under Computer\HKEY_LOCAL_MACHINE\BCD00000000.
Would it not be better to block the deletion if the subkey is ""? As this is a very annoying and difficult to catch.
Any ideas why it would happen just in windows 10?
Thanks again
Thanks for your replies. I am can now give you the actual revision details.
The issue is in both v2.44 and v3.02.
The entire tree does not get deleted just the Description Folder under Computer\HKEY_LOCAL_MACHINE\BCD00000000.
Would it not be better to block the deletion if the subkey is ""? As this is a very annoying and difficult to catch.
Any ideas why it would happen just in windows 10?
Thanks again
Can you please clarify if you are passing "' or "()" as the path?
The actual code used :
DeleteRegKey HKLM "$(MY_REGKEY)"
MY_REGKEY is not declared anywhere in the script.
DeleteRegKey HKLM "$(MY_REGKEY)"
MY_REGKEY is not declared anywhere in the script.
Yes, that turns into a empty string, but the compiler should be warning you with "LangString "MY_REGKEY" is not set in language table of language 1033"
Yes the warning was shown but unfortunately ignored. I am afraid this is common with warnings.
Now that you see the problem is there any chance that it could be upgraded to an error rather than a warning or some other measure to prevent the issue?
Thanks
Now that you see the problem is there any chance that it could be upgraded to an error rather than a warning or some other measure to prevent the issue?
Thanks
You can compile with /WX to turn warnings into errors.
It is not possible to fully detect this empty string in the compiler but we could perhaps avoid it at run-time.
It is not possible to fully detect this empty string in the compiler but we could perhaps avoid it at run-time.
You can add /WX to the makensis command line, this treats warnings as errors.
Ok, this is helpful but not useful as it only takes one user not to add the arguments to get into the situation. I think the problem can occur in other ways too.
DeleteRegKey HKLM ""
DeleteRegKey HKLM "$(MY_REGKEY)" where MY_REGKEY is defined as ""
In any case the big questions for me is in relation to :
1.Why only the HKEY_LOCAL_MACHINE\BCD00000000\Description entry is deleted and not the whole tree.
Thanks again for your help
DeleteRegKey HKLM ""
DeleteRegKey HKLM "$(MY_REGKEY)" where MY_REGKEY is defined as ""
In any case the big questions for me is in relation to :
1.Why only the HKEY_LOCAL_MACHINE\BCD00000000\Description entry is deleted and not the whole tree.
I don't know if a empty string is a bug, you are basically asking it to delete the entire tree.2. Who can answer the question :
If we should allow you to do that is another question.3. Why it only occurs on Windows 10?
Thanks again for your help
We could detect "" and "${xyz}" in the compiler. Possibly "$(xyz)" but not "$xyz", that can only be detected at run-time. The soon to be released NSIS v3.03 will also allow you to turn warnings into errors in the .nsi with a !pragma.
1) To delete a registry key we have to delete all the children first. The order of keys returned by Windows is undefined. When we find a child key we cannot delete the whole operation is aborted but the already deleted keys are gone.
2) I will try to discuss it with kichik before the next release. I have already added some basic code to installers to try to stop this. We are however a little bit in undefined territory here. You are allowed to open a "" subkey but MSDN does not specify what happens when you try to delete one. We call RegDeleteKeyEx if it is available and RegDeleteKey if not and things might also vary depending on the Windows version and if it is 64-bit or not (the WOW64 layer might not be 100% compatible with the "real thing").
3) It looks like there is something wrong/changed with the ACL on the BCD00000000\Description key on Windows 10. On Windows 8 you would not be able to delete it so easily. The next key (Objects) however is more locked down so the delete operation would end there.
1) To delete a registry key we have to delete all the children first. The order of keys returned by Windows is undefined. When we find a child key we cannot delete the whole operation is aborted but the already deleted keys are gone.
2) I will try to discuss it with kichik before the next release. I have already added some basic code to installers to try to stop this. We are however a little bit in undefined territory here. You are allowed to open a "" subkey but MSDN does not specify what happens when you try to delete one. We call RegDeleteKeyEx if it is available and RegDeleteKey if not and things might also vary depending on the Windows version and if it is 64-bit or not (the WOW64 layer might not be 100% compatible with the "real thing").
3) It looks like there is something wrong/changed with the ACL on the BCD00000000\Description key on Windows 10. On Windows 8 you would not be able to delete it so easily. The next key (Objects) however is more locked down so the delete operation would end there.