readmedottxt Posted February 14, 2011 Share Posted February 14, 2011 I have a workgroup computer. I need to remove a user from the Administrators group. This always fails, can anyone point me in the right direction? $varUser = InputBox("user to remove from admins group", "", "") $objGroup = ObjGet("WinNT://./Administrators") $objLocalMember = ObjGet("WinNT://./" & $varUser) $objGroup.Remove($objLocalMember.ADsPath) Link to comment Share on other sites More sharing options...
Juvigy Posted February 14, 2011 Share Posted February 14, 2011 WMI is a little bit tricky.Try this instead. $path="net localgroup Administrators Username /Remove" RunWait(@ComSpec & ' /c ' & $path) Link to comment Share on other sites More sharing options...
UEZ Posted February 14, 2011 Share Posted February 14, 2011 Try this: ;coded by UEZ 2011 $srv = "." $LocalGroup_Name = "Administrators" $user = "Test" $objGroup = ObjGet("WinNT://" & $srv & "/" & $LocalGroup_Name & ",group") If IsObj($objGroup) then For $objUser In $objGroup.Members If $objUser.Name = $user Then $objGroup.Remove($objUser.ADsPath) ExitLoop EndIf Next EndIf Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now