Guest User

SnoreToast - Register Program

a guest
Jan 13th, 2021
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. const childProcess = require('child_process');
  2. const path = require('path');
  3. const os = require('os');
  4.  
  5. function createProgram(id, name, executable = "") {
  6. // SnoreToast/Program Name Here.lnk
  7. name = 'SnoreToast/' + name;
  8. if (!name.endsWith('.lnk')) {
  9. name += '.lnk';
  10. }
  11.  
  12. const dir = path.dirname(require.resolve('node-notifier'));
  13. const exe = path.join(dir, 'vendor', 'snoreToast', `snoretoast-${os.arch()}.exe`);
  14. const args = [name, executable, id]
  15. .map(s => s.replace(/"/g, '\\"'))
  16. .join('" "');
  17.  
  18. const cmd = `${exe} -install "${args}"`;
  19. console.log("If this doesn't work, run this command manually:");
  20. console.log(cmd);
  21. console.log();
  22. console.log("If that doesn't work, change the Program Name (in the terminal) and then try again.",
  23. "This should fix it, but this is a really finnicky process.");
  24. childProcess.execSync(cmd);
  25. }
  26.  
  27. // Super finnicky. Give it a few minutes if it doesn't work right away.
  28. // Creating lots of these tends to cause some issues when done repeatedly.
  29. createProgram('ProgramName.UNIQUE_ID', 'Program Name Here');
  30.  
Advertisement
Add Comment
Please, Sign In to add comment