You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

windowselevate.hta 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <html><HTA:APPLICATION ID="windowselevate" icon="#"/>
  2. <script language="vbscript">
  3. document.title = "elxr control panel"
  4. self.ResizeTo 200,600
  5. Sub Window_Onload
  6. self.MoveTo (screen.availWidth - (document.body.clientWidth + 40)),10
  7. End Sub
  8. Set objShell = CreateObject("WScript.Shell")
  9. Set objENV = objShell.Environment("Process")
  10. dim NODE_ENV
  11. NODE_ENV = objENV("NODE_ENV")
  12. </script>
  13. <script language="javascript">
  14. //WINDOWSTATE="minimize" SHOWINTASKBAR="no" SYSMENU="no" CAPTION="no"
  15. // https://devblogs.microsoft.com/scripting/how-can-i-pass-command-line-variables-to-an-hta-when-it-starts/
  16. // alert(windowselevate.commandLine)
  17. var args = windowselevate.commandLine.split('"').slice(3);
  18. // alert(args)
  19. var processedArgs = { _ : [] }
  20. var namedArgs = [];
  21. for(var item in args){
  22. if(args[item].charAt(0) === '-'){
  23. namedArgs.push(args[item])
  24. var split = args[item].split('=');
  25. processedArgs[split[0].slice(2)] = split[1] || true;
  26. }
  27. else processedArgs._.push(args[item]);
  28. }
  29. // args = args.forEach(function(item){ })
  30. // alert('processedArgs._ : ' + processedArgs._);
  31. // alert(processedArgs.runas);
  32. // PB : TODO -- Convert all the cli args back to string.
  33. var cargs = (processedArgs.debug ? '--inspect-brk=9228' : '') + ' elxr ' + processedArgs._.join(' ') + ' ' + namedArgs.join(' ');
  34. // alert(cargs)
  35. var shell = new ActiveXObject('shell.application');
  36. shell.ShellExecute('node', cargs, '', 'runas', 1);
  37. var fso = new ActiveXObject('Scripting.FileSystemObject');
  38. window.onload = function() {
  39. document.body.style.backgroundColor = 'black';
  40. document.body.style.fontFamily = 'arial';
  41. var log = document.createElement('div');
  42. log.innerHTML='Please Wait';
  43. function l(msg){ log.innerHTML+= msg; };
  44. log.style.color = 'blue';
  45. log.style.width = '95%';
  46. log.id = 'log';
  47. document.body.appendChild(log);
  48. l('<Br/>Current config : ')
  49. l('<Br/>NODE_ENV = ' + NODE_ENV)
  50. l('<Br/>cmd = ' + processedArgs._[0])
  51. processedArgs._[1] === 'use' ? l('<Br/>using = ' + processedArgs._[2]) : null;
  52. l('<Br/><Br/>')
  53. var timer = function(){
  54. l('.');
  55. if(fso.FileExists("run.done")) close();
  56. else window.setTimeout(timer, 1000);
  57. };
  58. window.setTimeout(timer, 3000);
  59. };
  60. </script>
  61. </html>