Skip to content

Instantly share code, notes, and snippets.

@tondrej
Last active October 30, 2020 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tondrej/be7d5b95053f19b5dddd9aa57c1af59c to your computer and use it in GitHub Desktop.
Save tondrej/be7d5b95053f19b5dddd9aa57c1af59c to your computer and use it in GitHub Desktop.
chakracore-delphi WMI example
// ask host to create an Automation object instance
let locator = createOleObject('WbemScripting.SWbemLocator');
const computerName = '.';
const namespace = '';
const userName = '';
const password = '';
// use it (access its properties and methods) from Javascript
let service = locator.ConnectServer(computerName, namespace, userName, password);
const className = 'Win32_OperatingSystem';
console.log(`***** InstancesOf('${className}') *****`);
let items = service.InstancesOf(className);
items.forEach((item, i) => {
if (i > 0) {
console.log('');
}
item.Properties_.forEach((p) => {
console.log(`${p.Name}: ${item[p.Name]}`);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment