You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Read and Write to the Windows registry in-process from Node.js. Easily set application file associations and other goodies & such. You can also enable your application to run processes as an Administrator.
5
+
Read and Write to the Windows registry in-process from Node.js. Easily set application file associations and launch processes as an Administrator.
6
6
7
7
## Install
8
8
9
-
This library interacts with native Windows APIs. Ensure you have Visual Studio 2013 or newer build tools. Using Visual Studio is not
10
-
required. Then install the package:
9
+
This library interacts with native Windows APIs. To add this module to your Node application, install the package:
11
10
12
11
```
13
12
npm install windows-registry-node
13
+
14
14
```
15
15
16
+
To install node modules that require compilation on Windows, make sure you have installed the [necessary build tools](https://github.com/nodejs/node-gyp#installation). Specifically, we need `npm install -g node-gyp`, a cross-platform cli written in Node.js for native addon modules for Node.js.
17
+
18
+
To install `node-gyp`, install [python v2.7.3](http://www.python.org/download/releases/2.7.3#download) and [Visual Studio 2013 build tools](http://www.microsoft.com/en-gb/download/details.aspx?id=44914). You do not need to install the full Visual Studio, only the build tools are required. Once the build tools are installed, you should be able to do `npm install -g node-gyp`.
19
+
16
20
## Creating File Associations
17
21
18
-
To create a file association, you can call the `fileAssociation.associateExeForFile` api which will make windows assign a default program for
19
-
an arbitrary file extension:
22
+
To create a file association, you can call the `fileAssociation.associateExeForFile` API, which will make windows assign a default program for an arbitrary file extension:
20
23
21
24
```js
22
25
var utils =require('windows-registry').utils;
23
26
utils.associateExeForFile('myTestHandler', 'A test handler for unit tests', 'C:\\path\\to\\icon', 'C:\\Program Files\\nodejs\\node.exe %1', '.zzz');
27
+
24
28
```
25
-
## Reading / Writing to the Windows Registry
29
+
After running the code above, you will see files with the extension of `.zzz` will be automatically associated with the Node program and their file icon will be changed to the Node file icon.
@@ -91,14 +104,18 @@ var value = key.getValue('test_value_name');
91
104
92
105
The return value depends on the type of the key (REG_SZ for example will give you a string).
93
106
94
-
## Launching a Process as An Admin
107
+
## Launching a Process as an Admin
95
108
96
-
To launch a process as an Administrator, you can call the `uac.elevate`api, which will launch a process as an Administrator causing the UAC (User Account Control) elevation prompt to appear if required. This is similar to the Windows Explorer command "Run as administrator". Pass in `FILEPATH` to the process you want to elevate. Pass in any`PARAMETERS` to run with the process. Since this is an asychronous call, pass in a callback to handle user's selection.
109
+
To launch a process as an Administrator, you can call the `uac.elevate`API, which will launch a process as an Administrator causing the UAC (User Account Control) elevation prompt to appear if required. This is similar to the Windows Explorer command "Run as administrator". Pass in `FILEPATH` to the process you want to elevate. Pass in any`PARAMETERS` to run with the process. Since this is an asynchronous call, pass in a callback to handle user's selection.
97
110
98
111
```js
99
-
var uac =require('windows-registry').uac;
100
-
uac.elevate('C:\\Program Files\\nodejs\\node.exe', 'index.js', function (err, result){console.log('callback');});
112
+
var utils =require('windows-registry').utils;
113
+
utils.elevate('C:\\Program Files\\nodejs\\node.exe', 'index.js', function (err, result){console.log(result);});
114
+
101
115
```
116
+
The process you want to launch with admin access will only be launched after the callback is called and only if the user clicks Yes in the UAC prompt. Otherwise, the process will not be launched. If the user is already running as an admin, the UAC prompt will not be triggered and the process you provided will be launched as an administrator automatically.
117
+
118
+

0 commit comments