def main()

in cortado/rtas/recycle_bin_process.py [0:0]


def main():
    log.info("Execute files from the Recycle Bin")
    target_dir = None
    for recycle_path in RECYCLE_PATHS:
        if Path(recycle_path).exists():
            target_dir = _common.find_writeable_directory(recycle_path)
            if target_dir:
                break
    else:
        log.info("Could not find a writeable directory in the recycle bin")
        raise _common.ExecutionError("Could not find a writeable directory in the recycle bin")

    if not target_dir:
        raise _common.ExecutionError("No writable directories in `RECYCLE_PATHS`")

    log.info("Running commands from recycle bin in %s" % target_dir)
    target_path = Path(target_dir) / "recycled_process.exe"

    target_app_exe = _common.get_resource_path(TARGET_APP_EXE)
    _common.copy_file(target_app_exe, target_path)
    _ = _common.execute_command(str(target_path), shell=True)

    time.sleep(0.5)
    _common.remove_file(target_path)

    cmd_path = _common.get_cmd_path()
    _common.copy_file(cmd_path, target_path)
    _ = _common.execute_command(
        [target_path, "/c", "echo hello world"],
    )
    time.sleep(0.5)
    _common.remove_file(target_path)