Skip to content

Instantly share code, notes, and snippets.

@Dragod
Last active October 5, 2021 15:40
Embed
What would you like to do?
Catch exexSync errors

If you want to get net wlan show profiles output no matter if it fails or not, you can use either asynchronous version of exec. The callback will have stdout set.

Or you can catch exception and get stdout from there. Something like:

let nestsh_output;
try {
  netsh_output = execSync('netsh wlan show profiles');
} catch (ex) {
  netsh_output = ex.stdout;
}

That said, I don't see any issue with Node.js here, so I will close this. If you think that there is a bug here feel free to reopen the issue. If you have more questions about how to do stuff in Node.js, check out https://github.com/nodejs/help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment