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)
示例#2
0
def fDeleteRecovery():
    # Delete the recovery path to clean up after the application ran.
    if mFileSystem.fbIsFolder(sEdgeRecoveryPath):
        mFileSystem.fbDeleteChildrenFromFolder(sEdgeRecoveryPath)
示例#3
0
def fFirefoxCleanup():
  if mFileSystem.fbIsFolder(sFirefoxProfilePath):
    mFileSystem.fbDeleteChildrenFromFolder(sFirefoxProfilePath);
  else:
    assert mFileSystem.fbCreateFolder(sFirefoxProfilePath), \
        "Cannot create Firefox profile folder %s" % sFirefoxProfilePath;
示例#4
0
def fEdgeCleanup():
  if mFileSystem.fbIsFolder(sEdgeRecoveryPath):
    mFileSystem.fbDeleteChildrenFromFolder(sEdgeRecoveryPath);