Jump to content

MoveUser.EXE replacement (WIN32_UserProfile)


trtkron

Recommended Posts


If anyone else needs it, I finally got something working.

Set oShare = GetObject("winmgmts:\\.\root\CIMV2").Get("Win32_UserProfile.SID=""" & sSIDLocal & """")
Set oInParam = oShare.Methods_("ChangeOwner").InParameters.SpawnInstance_()

oInParam.Properties_.Item("Flags") = 0
oInParam.Properties_.Item("NewOwnerSID") = sSIDDomain

Set oOutParams = GetObject("winmgmts:\\.\root\CIMV2").ExecMethod("Win32_UserProfile.SID=""" & sSIDLocal & """", "ChangeOwner", oInParam)

After that, to make it 'just like' MoveUser (at least how I use it here), delete the local account.

Set oAccount = GetObject("winmgmts:\\.\root\cimv2:Win32_UserAccount.Name=""" & sLocalUserID & """")
Set oUserProfile = GetObject("winmgmts:\\.\root\cimv2:Win32_UserProfile.SID='" & oAccount.SID & "'")
If MsgBox("Are you sure you want to delete " & frmMain.cmbLocalUserID.Text, vbYesNo) = vbYes Then
oUserProfile.Delete_
End If

Edited by trtkron
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...