def main()

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


def main():
    server, _, port = _common.serve_dir_over_http()
    _common.clear_web_cache()

    target_app = Path("mydotnet.exe")
    _common.patch_file_with_bytes(
        _common.get_resource_path(MY_DOT_NET_EXE),
        _common.as_wchar(":8000"),
        _common.as_wchar(":%d" % port),
        target_file=target_app,
    )

    install_util64 = "C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\InstallUtil.exe"
    install_util86 = "C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\InstallUtil.exe"

    install_util = None
    if Path(install_util64).is_file():
        install_util = install_util64
    elif Path(install_util86).is_file():
        install_util = install_util86

    if install_util:
        _common.clear_web_cache()
        _ = _common.execute_command([install_util, "/logfile=", "/LogToConsole=False", "/U", target_app])

    else:
        log.info("Unable to find InstallUtil, creating temp file")
        install_util = Path("InstallUtil.exe").resolve()
        _common.copy_file(sys.executable, install_util)
        _ = _common.execute_command(
            [
                install_util,
                "-c",
                "import urllib; urllib.urlopen('http://%s:%d')" % (_common.get_host_ip(), port),
            ]
        )
        _common.remove_file(install_util)

    _common.remove_file(target_app)
    server.shutdown()