Beispiel #1
0
def uninstall_integration():
	for SubKey in (os.path.join ('Software', 'Classes', 'CrySelect.engine'), os.path.join ('Software', 'Classes', 'CrySelect.project')):
		try:
			win32api.RegDeleteTree (win32con.HKEY_CURRENT_USER, SubKey)
		except pywintypes.error:
			pass
		try:
			win32api.RegDeleteTree (win32con.HKEY_LOCAL_MACHINE, SubKey)
		except pywintypes.error:
			pass
Beispiel #2
0
def reset_intellij(records):
    """
    :return:
    """
    import os
    import win32api
    import win32con

    win32api.MessageBox(None, '按任意键开始重置试用信息', '开始重置', win32con.MB_OK)

    key = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, 'SOFTWARE\\JavaSoft\\Prefs\\jetbrains')
    if key:
        text = ''
        for (name, *_) in win32api.RegEnumKeyEx(key):
            if name in records:
                try:
                    win32api.RegDeleteTree(key, name)
                    text += '删除注册表: %s\n' % name
                    evaluation_key_path, other_xml_path = records[name]
                    os.remove(evaluation_key_path)
                    text += '删除文件: %s\n' % evaluation_key_path
                    os.remove(other_xml_path)
                    text += '删除文件: %s\n' % other_xml_path
                except Exception as ex:
                    win32api.MessageBox(None, ex, '异常信息', win32con.MB_OK | win32con.ICON_ERROR)
        win32api.RegCloseKey(key)
        win32api.MessageBox(None, text, '重置完成', win32con.MB_OK)
def uninstall_integration():
    """
    Removes all entries from CryVersionSelector in the Windows registry.
    """
    if not HAS_WIN_MODULES:
        return

    for subkey in (os.path.join('Software', 'Classes', 'CrySelect.engine'),
                   os.path.join('Software', 'Classes', 'CrySelect.project')):
        try:
            win32api.RegDeleteTree(win32con.HKEY_CURRENT_USER, subkey)
        except pywintypes.error:
            pass
        try:
            win32api.RegDeleteTree(win32con.HKEY_LOCAL_MACHINE, subkey)
        except pywintypes.error:
            pass
def main():
    print __doc__
    print "Start cleaning registry ..."
    print ""
    
    for view in (VIEW64, VIEW32):
        hRoot = HKCR
        for subkey1 in [r'', r'TypeLib', r'CLSID', r'Interface', r'Record']:
            hKey = win32api.RegOpenKeyEx(hRoot, subkey1, 0, view)
            for subkey2, r, c, l in win32api.RegEnumKeyEx(hKey):
                if subkey2.startswith(STARTSWITH_GUID) or subkey2.startswith(STARTSWITH_PROGID):
                    print '\\'.join((HKMAP[hRoot] + VIEWMAP[view], subkey1, subkey2)).replace('\\\\', '\\')
                    try:
                        win32api.RegDeleteTree(hKey, subkey2)
                    except Exception as ex :
                        print ' failed: %s' % ex.strerror
            win32api.RegCloseKey(hKey)
    
    print "\nDone"
Beispiel #5
0
def OverrideSignature():
    print1("Using Override Signature. Refreshing")
    OutlookCom = WaitForOutlook()
    WordCom, DocuCom, Active = ClearDockLocks(
        config.Settings['OverrideSignature'])
    wdFormatRTF = 6
    wdFormatHTML = 8
    wdFormatText = 2
    DocuCom.SaveAs("%s.txt" % config.Settings['OutlookSignature'],
                   wdFormatText)
    DocuCom.SaveAs("%s.rtf" % config.Settings['OutlookSignature'], wdFormatRTF)
    DocuCom.SaveAs("%s.htm" % config.Settings['OutlookSignature'],
                   wdFormatHTML)
    SetOutlookDefaults(WordCom)
    print1("Done Override")
    HKCU = win32api.RegOpenCurrentUser()
    win32api.RegDeleteTree(HKCU, config.Settings['RegistryLocation'])
    DocuCom.Close()
    if (not Active): WordCom.Quit()
def CleanRegistryEntry(expectation_name, expectation, variable_expander):
    """Cleans registry keys and/or values based on expectations.

    Args:
        expectation_name: The registry key being cleaned.
        expectation: A dictionary describing the state of the key:
            'exists': Either the string 'forbidden', indicating that the key is
                to be deleted if it is found, or the string 'optional',
                indicating that specific values in the key are to be deleted if
                the key exists.
            'values' (optional): For a key with 'optional' existence, a
                dictionary mapping value names to empty dicts, indicating that
                the values are to be deleted.
        variable_expander: A VariableExpander object.

    Raises:
        AssertionError: If an expectation is not satisfied.
        WindowsError: If an error occurs while cleaning the registry.
    """
    key = variable_expander.Expand(expectation_name)
    assert not expectation['exists'] == 'required', (
        'Invalid expectation for CleanRegistryEntry operation: \'exists\' ' +
        'property for key %s must not be \'required\'' % key)
    root_key, sub_key = key.split('\\', 1)

    registry_view = _winreg.KEY_WOW64_32KEY
    if 'wow_key' in expectation:
        registry_view = _RegistryViewConstant(expectation['wow_key'])
    elif variable_expander.Expand('$MINI_INSTALLER_BITNESS') == '64':
        registry_view = _winreg.KEY_WOW64_64KEY

    try:
        # Query the Windows registry for the registry key. It will throw a
        # WindowsError if the key doesn't exist.
        key_handle = _winreg.OpenKey(_RootKeyConstant(root_key), sub_key, 0,
                                     (_winreg.KEY_SET_VALUE | registry_view))
    except WindowsError:
        # There is nothing to clean if the key doesn't exist.
        return

    if expectation['exists'] == 'forbidden':
        # RegDeleteTree must be called with a handle on some parent of the key
        # to be deleted in order for it to remove the key itself and not only
        # its values and subkeys. Open the root of the hive with the proper
        # permissions, then delete the key by name.
        key_handle = None
        root_handle = _winreg.OpenKey(
            _RootKeyConstant(root_key), None, 0,
            (win32con.DELETE | _winreg.KEY_ENUMERATE_SUB_KEYS
             | _winreg.KEY_QUERY_VALUE | _winreg.KEY_SET_VALUE
             | registry_view))
        win32api.RegDeleteTree(root_handle, sub_key)
        LOGGER.info('CleanRegistryEntry deleted key %s' % key)
        return

    assert 'values' in expectation and expectation['values'], (
        'Invalid expectation for CleanRegistryEntry operation: a \'values\' ' +
        'dictionary is required for optional key %s' % key)
    for value, value_expectation in expectation['values'].iteritems():
        value = variable_expander.Expand(value)
        assert 'type' not in value_expectation, (
            'Invalid expectation for CleanRegistryEntry operation: value ' +
            '%s\\%s must not specify a \'type\'' % (key, value))
        try:
            _winreg.DeleteValue(key_handle, value)
            LOGGER.info('CleanRegistryEntry deleted value %s\\%s' %
                        (key, value))
        except WindowsError as e:
            if e.winerror == winerror.ERROR_FILE_NOT_FOUND:
                continue
            raise
Beispiel #7
0
 def DeleteTree(self, name):
     win32api.RegDeleteTree(self.handle, name)