1

I created a little script that download and install python3 silently on Windows.

The problem is that I need to launch CMD as admin before using node myfile.js.

Is this a way to ask people to execute as admin in the beginning of the nodejs script?

I also need a way to change the system PATH to add python PATH permanently. Is this possible?

user3551444
  • 109
  • 10

2 Answers2

3

Welcome to the world of installers.

1 Official Microsoft's answer is use the Windows Installer (*.msi). Windows will run it and take care of the elevated access rights automatically.

You can create MSI scripts using free tools like WiX Toolset.

2 If you don't want to go the steep official way and still want a decent support for operations like changing the system PATH then Jordan Russel's Inno Setup is very powerful free install builder that can be programmed to do nearly anything using the built-in Pascal script.

3 You can of course do it your way using a little scripts and hitting all the obstacles again. It is certainly possible, some answers are available here on Stack Overflow, e.g.

Community
  • 1
  • 1
xmojmr
  • 8,073
  • 5
  • 31
  • 54
0

I found a very simple solution:

var exec = require('child_process').exec;

exec('setx /m PATH "%PATH%;c:\\DevTools\\python3"');
user3551444
  • 109
  • 10