Node-webkit Setup program boot up

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.