def SvcDoRun(self): self.is_running = True servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTED, ("hello", "")) #current_location = str(os.path.abspath(os.path.dirname(sys.argv[0]))) # 현재 위치 체크 while self.is_running: # self.is_running이 True인 경우에만 while 실행 rc = win32event.WaitForSingleObject(self.hWaitStop, 5000) if rc == win32event.WAIT_OBJECT_0: break else: #subprocess.Popen([current_location + "\\Main.exe"]) # 현재 경로에 위치한 Main.exe # TEST #f = open('e:/download/1/a.log', 'a') #f.write(datetime.datetime.now().isoformat()) #f.close() reg = WinRegistry() path = r'HKCU\Control Panel\Desktop' keyvalue = reg.read_key(path) for v in keyvalue['values']: if v['value'] == 'SCRNSAVE.EXE': if v['data'] != 'c:\\Windows\\System32\\PhotoScreensaver.scr': reg.delete_value(path, 'SCRNSAVE.EXE') reg.write_value( path, 'SCRNSAVE.EXE', 'c:\\Windows\\System32\\PhotoScreensaver.scr') time.sleep(60)
def register_project_engine(config, prompt_path=True): """ Register the projects engine :return: True on success """ reg = Reg() try: registered_engines = reg.read_key(config.UE4EngineBuildsReg)['values'] for engine in registered_engines: eng_val = engine['value'] # type:str if eng_val.startswith('{') and eng_val.endswith('}'): click.secho("Removing arbitrary Engine Association {0}".format( eng_val)) reg.delete_value(config.UE4EngineBuildsReg, engine['value']) except Exception: # No entries yet, all good! pass if check_engine_dir_valid(config.UE4EnginePath): click.secho('Setting engine registry key {0} to {1}'.format( config.UE4EngineKeyName, config.UE4EnginePath)) try: reg.create_key(config.UE4EngineBuildsReg) except Exception: pass reg.write_value(config.UE4EngineBuildsReg, config.UE4EngineKeyName, config.UE4EnginePath, 'REG_SZ') elif prompt_path: my_engine_path = input('Enter Engine Path: ') if check_engine_dir_valid(my_engine_path): click.secho('Setting engine registry key {0} to {1}'.format( config.UE4EngineKeyName, my_engine_path)) reg.write_value(config.UE4EngineBuildsReg, config.UE4EngineKeyName, my_engine_path, 'REG_SZ') else: print_error( "Could not find engine path, make sure you type the full path!" ) return False else: print_error("Could not find engine path!") return False return True
class Keywords(object): def __init__(self, host=None): self.reg = Reg(host) def read_registry_key(self, key, key_wow64_32key=False): """ Reading registry key """ resp = self.reg.read_key(key, key_wow64_32key) return resp def create_registry_key(self, key, key_wow64_32key=False): """ Creating registry key """ self.reg.create_key(key, key_wow64_32key) def delete_registry_key(self, key, key_wow64_32key=False): """ Deleting registry key """ self.reg.delete_key(key, key_wow64_32key) def read_registry_value(self, key, value, key_wow64_32key=False): """ Reading value from registry """ return self.reg.read_value(key, value, key_wow64_32key) def write_registry_value(self, key, value, data=None, reg_type='REG_SZ', key_wow64_32key=False): """ Writing (or creating) data in value """ self.reg.write_value(key, value, data, reg_type, key_wow64_32key) def delete_registry_value(self, key, value, key_wow64_32key=False): """ Deleting value from registry """ self.reg.delete_value(key, value, key_wow64_32key)