Thursday, July 29, 2021

Getting Stata automation working without administrative priveleges

"You have no power here!"

If you're using Stata on Windows, Stata automation is really powerful. It can allow you to efficiently use Jupyter notebooks using stata_kernel (or IPyStata's automation interface). The "installation", however, typically requires admin right. If you have a non-admin user, here's how to do it.

Installation consists of registering the Stata type library in the Windows Registry. The default process adds entries in the HKEY_CLASSES_ROOT root, which is not user-editable. With a bit of tweaking, however, these entries can work if installed in HKEY_CURRENT_USER, which is user-editable. Here is my modified reg entry used for Stata 15. It worked for both SE and MP flavors. Possibly it works for other versions. You can copy it to the target system,  edit the Stata path if different, rename it from .txt to .reg, and imported using regedit.exe.[1]

Here are the steps to I took in case one needs to replicate the procedure (e.g., if the above does not work for you). I did the registration on a system where I did have admin rights and logged what was added to the registry using NirSofts RegFromApp:

RegFromApp.exe /AutoSave "modified.reg" "original.reg" /RunProcess "C:\Program Files (x86)\Stata15\StataMP-64.exe" /ProcessParams "/Register"

Then I following these instructions to modify modified.reg.[2]  Hope that helps

[1] If you don't have access to Regedit then you can try C:\Windows\System32\reg.exe import modified.reg.

[2] Note, that when I registered, unregistered, and re-registered again, the second time it was missing some keys: in HKCU\SOFTWARE\Classes\: AppID\stata.EXE, AppID\<GUID from previous>, stata.StataOLEApp.1, stata.StataOLEApp.1\CLSID, stata.StataOLEApp, stata.StataOLEApp\CLSID, stata.StataOLEApp\CurVer.