Skip to content

Instantly share code, notes, and snippets.

@hmbrg
Last active February 27, 2016 17:08
Show Gist options
  • Select an option

  • Save hmbrg/e8cdfdc53a8e8b2ae3a8 to your computer and use it in GitHub Desktop.

Select an option

Save hmbrg/e8cdfdc53a8e8b2ae3a8 to your computer and use it in GitHub Desktop.
Get screen resulution on windows using node
const spawn = require('child_process').spawn;
const bat = spawn('cmd.exe', ['/c', __dirname + '/getScreenRes.bat']);
bat.stdout.setEncoding('utf8');
var out = "";
bat.stdout.on('data', (data) => {
out = out + data;
});
bat.stderr.on('data', (data) => {
out = out + data;
});
bat.on('exit', (code) => {
const arrout = out.split("\n");
console.log(arrout[0]);
console.log(arrout[1]);
});
@echo off
for /f "delims=" %%# in ('"wmic path Win32_VideoController get CurrentHorizontalResolution,CurrentVerticalResolution /format:value"') do (
set "%%#">nul
)
echo %CurrentHorizontalResolution%
echo %CurrentVerticalResolution%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment