Tomasz Onyszko log:
[...]
Sprytnie.
Z całym (ciąglym) szacunkiem i podziwem Tomaszu, ale wyszło i tak na moje:-)
Nie podałeś 5'-owego "gotowca" zatem "nie chcem, ale muszem" ;-)
Change_UserName2.vbs (do użycia bezpośrednio na local)
---------------------------------
sNewUser = "Aya"
Set oWshNet = CreateObject("WScript.Network")
sComputerName = oWshNet.ComputerName
sOldUser = "Bee"
On Error Resume Next
Set oUser = GetObject("WinNT://" & sComputerName & "/" _
& sOldUser & ", user")
If LCase(sNewUser) <> LCase(sOldUser) Then
Set oComputer = GetObject("WinNT://" & sComputerName)
Set oNewUser = oComputer.MoveHere(oUser.ADsPath, sNewUser)
End If
On Error Goto 0
Function GetUserName(sComputerName)
Dim sUserSID, oWshNetwork, oUserAccount
Set oUserAccounts = GetObject( _
"winmgmts:{impersonationLevel=impersonate}!//" _
& sComputerName & "/root/cimv2").ExecQuery( _
"Select Name, SID from Win32_UserAccount WHERE Domain = '" _
& sComputerName & "'")
On Error Resume Next
For Each oUserAccount In oUserAccounts
If Left(oUserAccount.SID, 9) = "S-1-5-21-" And _
Right(oUserAccount.SID, 4) = "-205" Then
GetUserName = oUserAccount.Name
Exit For
End if
Next
End Function
------------------
-- Best regards! :-)Received on Fri Sep 29 18:45:13 2006
To archiwum zostało wygenerowane przez hypermail 2.1.8 : Fri 29 Sep 2006 - 19:42:04 MET DST