The keyword for the WMI way is "joindomainorworkgroup". Search on that, and you may find a way to do it without netdom.