Exemplo n.º 1
0
def fEdgeCleanup():
  # RuntimeBroker.exe can apparently hang with dbgsrv.exe attached, preventing Edge from opening new pages. Killing
  # all processes running either exe appears to resolve this issue.
  for uProcessId in fauProcessesIdsForExecutableNames(["dbgsrv.exe", "RuntimeBroker.exe"]):
    fbTerminateForProcessId(uProcessId);
  
  # Delete the recovery path to prevent conserving state between different runs of the application.
  if not oEdgeRecoveryFolder.fbIsFolder():
    return;
  if oEdgeRecoveryFolder.fbDelete():
    return;
  # Microsoft Edge will have a lock on these files if its running; terminate it.
  oConsole.fPrint(WARNING, "Microsoft Edge appears to be running becasuse the recovery files cannot be");
  oConsole.fPrint(WARNING, "deleted. All running Microsoft Edge processes will now be terminated to try");
  oConsole.fPrint(WARNING, "to fix this...");
  # Microsoft Edge may attempt to restart killed processes, so we do this in a loop until there are no more processes
  # running.
  while 1:
    auProcessIds = fauProcessesIdsForExecutableNames(["MicrosoftEdge.exe", "MicrosoftEdgeCP.exe"])
    if not auProcessIds:
      break;
    for uProcessId in auProcessIds:
      fbTerminateForProcessId(uProcessId);
  if oEdgeRecoveryFolder.fbDelete():
    return;
  oConsole.fPrint(ERROR, "The recovery files still cannot be deleted. Please manually terminated all");
  oConsole.fPrint(ERROR, "processes related to Microsoft Edge and try to delete everything in");
  oConsole.fPrint(ERROR_INFO, oEdgeRecoveryFolder.sPath, ERROR, ".");
  os._exit(4);
def fEdgeCleanup():
    # RuntimeBroker.exe can apparently hang with dbgsrv.exe attached, preventing Edge from opening new pages. Killing
    # all processes running either exe appears to resolve this issue.
    for uProcessId in fauProcessesIdsForExecutableNames(
        ["dbgsrv.exe", "RuntimeBroker.exe"]):
        fbTerminateForProcessId(uProcessId)

    # Delete the recovery path to prevent conserving state between different runs of the application.
    if not mFileSystem.fbIsFolder(sEdgeRecoveryPath):
        return
    try:
        mFileSystem.fbDeleteChildrenFromFolder(sEdgeRecoveryPath,
                                               fbRetryOnFailure=lambda: False)
    except:
        pass
        # Failed to delete
    else:
        return
    # Microsoft Edge will have a lock on these files if its running; terminate it.
    oConsole.fPrint(
        WARNING,
        "Microsoft Edge appears to be running becasuse the recovery files cannot be"
    )
    oConsole.fPrint(
        WARNING,
        "deleted. All running Microsoft Edge processes will now be terminated to try"
    )
    oConsole.fPrint(WARNING, "to fix this...")
    # Microsoft Edge may attempt to restart killed processes, so we do this in a loop until there are no more processes
    # running.
    while 1:
        auProcessIds = fauProcessesIdsForExecutableNames(
            ["MicrosoftEdge.exe", "MicrosoftEdgeCP.exe"])
        if not auProcessIds:
            break
        for uProcessId in auProcessIds:
            fbTerminateForProcessId(uProcessId)
    try:
        mFileSystem.fbDeleteChildrenFromFolder(sEdgeRecoveryPath,
                                               fbRetryOnFailure=False)
    except:
        pass
        # Failed to delete
    else:
        return
    oConsole.fPrint(
        ERROR,
        "The recovery files still cannot be deleted. Please manually terminated all"
    )
    oConsole.fPrint(
        ERROR,
        "processes related to Microsoft Edge and try to delete everything in")
    oConsole.fPrint(ERROR_INFO, sEdgeRecoveryPath.replace("\\\\?\\", ""),
                    ERROR, ".")
    os._exit(4)
Exemplo n.º 3
0
def fKillRuntimeBrokerAndDbgSrv():
    for uProcessId in fauProcessesIdsForExecutableNames(
        ["dbgsrv.exe", "RuntimeBroker.exe"]):
        fbTerminateProcessForId(uProcessId)