From d22372f47e76e63761dfc7a0a2afa7b1a52e93cc Mon Sep 17 00:00:00 2001 From: arisudesu Date: Thu, 13 Jun 2024 17:30:33 +0300 Subject: [PATCH] fix: Username customization in localized Windows XP versions (#596) --- src/define.sh | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/src/define.sh b/src/define.sh index 3c3121d..7721537 100644 --- a/src/define.sh +++ b/src/define.sh @@ -2219,9 +2219,45 @@ prepareInstall() { { echo "Set WshShell = WScript.CreateObject(\"WScript.Shell\")" echo "Set WshNetwork = WScript.CreateObject(\"WScript.Network\")" - echo "Set oMachine = GetObject(\"WinNT://\" & WshNetwork.ComputerName)" - echo "Set oInfoUser = GetObject(\"WinNT://\" & WshNetwork.ComputerName & \"/Administrator,user\")" - echo "Set oUser = oMachine.MoveHere(oInfoUser.ADsPath,\"$username\")" + echo "Set Domain = GetObject(\"WinNT://\" & WshNetwork.ComputerName)" + echo "" + echo "Function DecodeSID(binSID)" + echo " ReDim o(LenB(binSID))" + echo "" + echo " For i = 1 To LenB(binSID)" + echo " o(i-1) = AscB(MidB(binSID, i, 1))" + echo " Next" + echo "" + echo " sid = \"S-\" & CStr(o(0)) & \"-\" & OctetArrayToString _" + echo " (Array(o(2), o(3), o(4), o(5), o(6), o(7)))" + echo " For i = 8 To (4 * o(1) + 4) Step 4" + echo " sid = sid & \"-\" & OctetArrayToString _" + echo " (Array(o(i+3), o(i+2), o(i+1), o(i)))" + echo " Next" + echo "" + echo " DecodeSID = sid" + echo "End Function" + echo "" + echo "Function OctetArrayToString(arr)" + echo " v = 0" + echo " For i = 0 To UBound(arr)" + echo " v = v * 256 + arr(i)" + echo " Next" + echo "" + echo " OctetArrayToString = CStr(v)" + echo "End Function" + echo "" + echo "For Each DomainItem in Domain" + echo " If DomainItem.Class = \"User\" Then" + echo " sid = DecodeSID(DomainItem.Get(\"objectSID\"))" + echo " If Left(sid, 9) = \"S-1-5-21-\" And Right(sid, 4) = \"-500\" Then" + echo " LocalAdminADsPath = DomainItem.ADsPath" + echo " Exit For" + echo " End If" + echo " End If" + echo "Next" + echo "" + echo "Call Domain.MoveHere(LocalAdminADsPath, \"$username\")" echo "" } | unix2dos > "$dir/\$OEM\$/admin.vbs"