executing a bat file in C:\ProgramData in nodejs

Viewed 27

The project I'm working on is a Nodejs + Electron application. I'm trying to execute a bat file located in

C:\ProgramData\ApplicationSettings

using const exec = require('child_process').exec;

I could execute the file just fine before i opted to move them to the programdata folder and try to execute it from there.

The code I was trying to use was

exec(path.join(String(process.env.programdata)+'/applicationSettings/', 'command.bat'))

Is this a path problem I am having or is it the fact that ProgramData is hidden? Is there any way for me to execute the bat file from my project?

1 Answers

Add function to see console output.

exec(..., (err, stdout, stderr)=>console.log(err?{err}:{stdout}))

And things should become clearer. Haven't you been mistaken in folder 'applicationsettings'? I have 'applicationData' on my Win10 and the access to it is restricted by default...

Related