Archive: Writing to registry becomes terribly slow


Writing to registry becomes terribly slow
My installer seems to be "stuck" in the middle of execution for about a minute. Debugging revealed that two harmless looking registry commands each take about 30 seconds:

WriteRegBin HKLM "SYSTEM\ControlSet001\services\openmapdrive" "FailureActions" 80510100000000000000000003000000140000000100000060ea000000000000000000000000000000000000

WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "OpenMapSysTray" "$INSTDIR\drive\OpenmapSystray.exe"

It only happens when I install a large amount of data (> 100 MB) some lines before. It works fine when I comment out this data, and also if I comment out the two registry commands (previous and subsequent calls to WriteRegStr work OK). I have no idea what could cause these commands to become so slow. Any ideas?


I don't know what might be causing this other than the disk cache forcing the registry be paged out but I do know that writing to ControlSet001 is probably wrong, 99.99% of the time you want the currentcontrolset!


Here's a crazy idea: How about first writing to registry, and then installing the >100MB data files?


@Anders: Thanks for pointing out the ControlSet problem. The speed problem, however, can't be caused by the disk cache, since it happens invariably at the same two lines, on different machines, with different memory sizes. It must be caused by some memory problem internal to NSIS.

@MSG: I tried that as a workaround, but now the installer freezes at the end, that is, the "Finish" button stays grayed out for about 40 seconds, although installation is complete. Which strengthens my suspicion that NSIS has problems handling the memory it has allocated for the 100MB+ of data.


Could it be related to a virusscanner hogging your system? A good way to test would be to disable all security software and compare results.


@MSG: Yes, indeed, when I disable my virus scanner, the lockup is gone. Thanks! Although I still don't understand why the lockup happens at two specific lines in the script. Also, when I replace the NSIS registry commands with nsExec::ExecToStack "reg add [...]", it becomes much faster (about 15 s instead of 30 s lockup per call).