I have been trying to set a registry key for the current logged in user using the following procedure, and it doesn’t appear to be working. The procedure is saying executed and completed successfully, but the reg key and value is not updated / created.
Key= "HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Security"## Here give the registry Key path
Sub_Key= "EnableRoamingFolderHomepages" ## Here give the sub Key of the registry
Field= "REG_DWORD" ##Here give the field of it
value = "2" ##Value required for Dynamics CRM Outlook plugin
import os;
import ctypes
class disable_file_system_redirection:
_disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
_revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
def __enter__(self):
self.old_value = ctypes.c_long()
self.success = self._disable(ctypes.byref(self.old_value))
def __exit__(self, type, value, traceback):
if self.success:
self._revert(self.old_value)
with disable_file_system_redirection():
set=os.popen('REG Add '+Key +'/v' + Sub_Key +'/t' + Field +'/d' +value +' /f').read();
print(set);
Can anyone see what is wrong with this and why it wont work…
I have updated my script and tested it on a test machine. The execution log shows as completed correcty, but it is still not creating the desired registry value.
Could you please tell me what kind of error exactly you have faced ? Is it not at all creating any reg value or not exactly created what you expected ?
Sometimes you will be having two “Office” path under here “HKEY_CURRENT_USER\Software\Microsoft\Office”. Kindly please describe me about the error exactly in order to make it success.