P
P
pawner_code2022-04-07 08:07:42
HTML
pawner_code, 2022-04-07 08:07:42

How to update registry data in electron after project build?

Greetings to all, the question is that after building the project on electron - updating the data in the registry does not work, running as administrator did not help. If you do not collect the project - everything works perfectly.

Here is my code that doesn't work after building the project - regedit.putValue.

ipcMain.on('nickname', (events, arg) => 
    {
        fs.writeFileSync(config_path, arg, 'utf-8');
        regedit.putValue(
        {
            'HKCU\\Software\\SAMP': {
                'PlayerName': {
                    type: 'REG_SZ',
                    value: arg
                }
            }
        }, 
        function(err) {
            console.log('regedit error: ' + err);
        });
    });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shamanov, 2022-04-07
@SilenceOfWinter

look in debug mode what's in the log, most likely the package is not transferred to the application folder
or

This software uses Windows Script Host to read and write to the registry. For that purpose, it will execute .wsf files. When packaging the app's dependencies with ASAR, node-regedit will not be able to access the windows script files, because they are bundled in a single ASAR file. Therefore it is necessary to store the .wsf files elsewhere, outside of the packaged asar file. You can set your custom location for the files with setExternalVBSLocation(location):

// Assuming the files lie in <app>/resources/my-location
const vbsDirectory = path.join(path.dirname(electron.remote.app.getPath('exe')), './resources/my-location');
regedit.setExternalVBSLocation(vbsDirectory);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question