Skip to content

Commit

Permalink
fix: Username customization in localized Windows XP versions (#596)
Browse files Browse the repository at this point in the history
  • Loading branch information
arisudesu authored Jun 13, 2024
1 parent 135f8a0 commit d22372f
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 additions & 3 deletions src/define.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit d22372f

Please sign in to comment.