The previous article wrote a package script to set up the boot during installation, this post was written by node. JS to control whether the program started with Windows system boot.
Home add a reference to windows-shortcuts in the project Package.json (manual https://github.com/j201/windows-shortcuts)
"Dependencies": {
"Windows-shortcuts": "*"
}
In npm install Windows-shortcuts, add a shortcut to the third-party package. Then judge the system, according to the system to generate the starting directory address, and finally use the Window-shortcuts to generate a shortcut, the startup directory after the creation of a successful boot.
var shortcut = require (' windows-shortcuts '), var fs=require ("FS"),//windows boot start if (Process.platform.match (/^win/)) {//boot directory var startupmenu= "",//appdata directory roming is win7,win8 and other similar systems boot directory if (/roaming/.test (Process.env.APPDATA)) { startupmenu=process.env.appdata+ "\\Microsoft\\Windows\\Start menu\\programs\\startup\\";} ELSE{//WINXP and other similar system boot directory Startupmenu=process.env.userprofile+ "\\" start "menu \ \ program \ \ start \ \";} The shortcut name generated under the directory var startuptarget=startupmenu+ "program name. lnk";//To copy the shortcut past the source program var sourceprograme=__dirname+ "\\nw.exe";// exists on Delete, does not exist create if (Fs.existssync (Startuptarget)) {Fs.unlink (Startuptarget,function (Err) {if (err) {Console.error (" Cancel boot error ", err);}})} Else{shortcut.create (Startuptarget,sourceprograme,function (Err) {if (err) {Console.error ("Set Boot boot error", err);}}}}
There is also a way to call Regedit to pass in parameters, and to write the registry also line.
In writing this process, found some information, began to use node. js's self-contained module FS, Fs.symlink soft links to generate shortcuts, found that only the link named EXE suffix will show the icon, the other can be used, but the picture is empty. And this is only in Win7, Win8 in these systems, under XP, error code:Enosys, because XP does not support Fs.symlink.
Node-webkit Setup program boot up