Browse Source

fix: Username customization in localized Windows XP versions (#596)

arisudesu 1 year ago
parent
commit
d22372f47e
1 changed files with 39 additions and 3 deletions
  1. 39 3
      src/define.sh

+ 39 - 3
src/define.sh

@@ -2219,9 +2219,45 @@ prepareInstall() {
 
 
   {       echo "Set WshShell = WScript.CreateObject(\"WScript.Shell\")"
   {       echo "Set WshShell = WScript.CreateObject(\"WScript.Shell\")"
           echo "Set WshNetwork = WScript.CreateObject(\"WScript.Network\")"
           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 ""
           echo ""
   } | unix2dos > "$dir/\$OEM\$/admin.vbs"
   } | unix2dos > "$dir/\$OEM\$/admin.vbs"