Reputation: 3052
If I try to run this code in my office-js add-in in Excel 2016 (Desktop), it throws an error and says Access is denied.
ngOnInit() {
console.log('Writing to localStorage...' );
localStorage.setItem('foo', 'bar');
console.log('done.');
}
However, this only happens on one computer, but works as expected on every other. Also, this code works perfectly fine running in any browser including IE 11. Further, if I run excel in Administrator mode, it also works as expected.
There is some permissions or something that are off, writing to localStorage in Excel's sandboxed instance of IE11, and I can't figure out where or what it is.
I think I have tried every fix on this related question and none of them seem to make a difference in this case (Access Denied for localstorage in IE10).
More Background: Initially, this worked on my computer (and I was trying to fix it for a co-worker), but I changed my CachePath registry key (as noted here: Access Denied for localstorage in IE10) to Local instead of LocalLow to be able to reproduce the bug on my box. However, after trying various things to fix it, even switching that registry key back to LocalLow doesn't resolve the issue on my box as I would've expected.
Update: Image of my CachePath registry key:
However, using process monitor, I can see it's using the wrong path and ignoring the registry key update:
Why is it ignoring my registry update?
Any ideas?
Upvotes: 2
Views: 1945
Reputation: 3052
Short Answer:
Close IE and Excel and run this command:
icacls %userprofile%\Appdata\LocalLow /t /setintegritylevel (OI)(CI)L
Still not working? Open up regedit and delete these two folder from the registry:
Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\Cache\Extensible Cache
Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\LowCache\Extensible Cache
Still not working? Delete the entire Internet Explorer folder from the registry:
Computer\HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer
Longer Answer:
Normally, IE11 running in Protected Mode inside Excel writes anything set in the localStorage object in javascript to this file location:
%userprofile%\AppData\LocalLow\Microsoft\Internet Explorer\DOMStore
Notice the LocalLow folder in the path. Most programs would write data to the Local directory (which is for data that only stays on the local machine vs data that is Roaming which will roam with their profile wherever they log in), but the Low on the LocalLow folder refers to something Windows introduced in Vista known as "Integrity" Levels. I belive in protected mode inside Excel, IE can only work with Low integrity level files and normally this is not a problem because everything in LocalLow should be LOW integrity.
The subfolder in LocalLow somehow get their integrity level set to something higher than low.
Fix this by setting everything in LocalLow back to LOW integrity:
icacls %userprofile%\Appdata\LocalLow /t /setintegritylevel (OI)(CI)L
More info here: https://stackoverflow.com/a/20848924/3806701
Somehow, IE11 is trying to write localStorage to the DOMStore directory, but under the LOCAL folder.
Finally, if none of the above solutions solve the problem and the registry's CachePath is correctly set to include LocalLow in the path, I deleted the following keys in the registry:
Probably a good idea to backup the registry first, just in case and as a best practice, and also make sure and close all instances of iexplore.exe, then delete these keys:
Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows \CurrentVersion\Internet Settings\5.0\Cache\Extensible Cache
Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows \CurrentVersion\Internet Settings\5.0\LowCache\Extensible Cache
Computer\HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer
For me this was better than re-installing IE, and the next time you start it it will think it's been reinstalled and will setup the registry folders correctly...
Upvotes: 4