I just personally prefer it when scripts clean up after themselves and get rid of stuff that is no longer needed.

Leaving a COM open for something that probably doesn't get used often just feel messy.

Also, there's the winner!


EDIT:
Didn't even notice the earlier version didn't work properly, had regread COM already open, so it kept getting the old result.

Also, you can make the new version a tiny bit faster:
Code:
alias regread {
  if (!$~com(r)) !.comopen r WScript.Shell
  !noop $~com(r,RegRead,3,bstr,$~1)
  !return $~com(r).result
}

Shorter COM name and ! in front of "noop" did the trick.

Last edited by Dazuz; 10/08/16 06:45 PM.