i need help to monitor the progressbar from dism.exe on windows systems. dism.exe is spawnd from my node.js script:
const { spawn, exec } = require('child_process');
const ls = exec('dism.exe /Unmount-Image /MountDir:"C:\\WinPE_amd64\\mount" /discard');
ls.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
ls.stderr.on('data', (data) => {
console.log(`stderr: ${data}`);
});
ls.on('close', (code) => {
console.log(`child process exited with code ${code}`);
});
The stdout on the terminal:
C:\Users\Admin\Desktop>node test.js stdout: Tool zur Imageverwaltung f�r die Bereitstellung Version: 10.0.17763.1
stdout: Bereitstellung des Abbilds wird aufgehoben
[= 2.0% ]
...
[===========================99.0%========================= ]
[==========================100.0%==========================]
stdout: Der Vorgang wurde erfolgreich beendet.
child process exited with code 0
C:\Users\Admin\Desktop>
I dont understand why the progressbar dont write to stdout/stderr. The "data" event is not fired when the progressbar is displayed/renderd
Can someone help me to get the progressbar passed as string in a cb/function?
The callback get's fired, but console.log did not work (i dont know exactly why, i think because the progressbard renders with in the same line \r and replace the text from console.log)
with util.insepct i get the exact output from dism. My callback:
const handleProgress = function handleProgress(str) {
str = util.inspect(str);
if (str.substring(0, 4) == "'\\r[") {
let precent = str.split("%")[0];
precent = precent.replace(/=/g, "");
precent = precent.substring(4);
precent = Number(precent);
console.log(precent);
//console.log(">> done %d%%", precent);
//socket.emit("installation.progress", precent);
} else {
// normal "stat" feedback
console.log("IN CB", str)
}
};
And now it works, ;)