How to close a HTA window from another HTA?

杀马特。学长 韩版系。学妹 提交于 2019-11-28 02:17:37

I just realized, that I can terminate the main window as well in beforeTopClose(). Fixed code below.

beforeTopClose = function () {
    var thisHta = {},
        thisHtaPath = lib.shell.currentDirectory + '\\index.hta', // Path to current HTA
        htas = new Enumerator(lib.wmiService.ExecQuery("Select * from Win32_Process Where name = 'mshta.exe'"));
    while (!htas.atEnd()) {
        if (htas.item().CommandLine.indexOf('_tools\\dlgbase') > -1) {
            htas.item().Terminate();
        }
        if (htas.item().CommandLine.indexOf(thisHtaPath) > -1) {
            thisHta = htas.item();
        }
        htas.moveNext();
    }
    thisHta.Terminate();
    return;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!