I try to copy a font with nodejs v14.17.0
to %localappdata%\Microsoft\Windows\Fonts
, when try with prompt I don't have problem
copy /B "Haloha Free Trial.ttf" /V %localappdata%\Microsoft\Windows\Fonts\
1 file(s) copied.
but when try with nodejs, I've this issue
[Error: EPERM: operation not permitted, copyfile 'D:\dev\test\javascript\font\Haloha Free Trial.ttf' -> 'C:\Users\omen\AppData\Local\Microsoft\Windows\Fonts'] {
errno: -4048,
code: 'EPERM',
syscall: 'copyfile',
path: 'D:\\dev\\test\\javascript\\font\\Haloha Free Trial.ttf',
dest: 'C:\\Users\\omen\\AppData\\Local\\Microsoft\\Windows\\Fonts'
}
This is my code
let options = process.argv.slice(2);
console.log(options[0]);
console.log(process.env.LOCALAPPDATA);
const locallAppdata = process.env.LOCALAPPDATA;
const fs = require('fs');
fs.copyFile( options[0], locallAppdata+'\\Microsoft\\Windows\\Fonts\\', (err) =>{
if(err) throw err;
console.log( argv[0] + " was copied ");
});
How to solve it ?