AlexM2222
Junior Member | Ðåäàêòèðîâàòü | Ïðîôèëü | Ñîîáùåíèå | Öèòèðîâàòü | Ñîîáùèòü ìîäåðàòîðó #NoTrayIcon #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $ipath = @ScriptDir Global $opath = "C:\Sources" Global $xmlname = "Unattend.xml" filescheck() Global $libiconvpath = $opath & "\libiconv" DirCreate($libiconvpath) FileInstall("libiconv\iconv.exe", $libiconvpath & "\iconv.exe") FileInstall("libiconv\libcharset-1.dll", $libiconvpath & "\libcharset-1.dll") FileInstall("libiconv\libiconv-2.dll", $libiconvpath & "\libiconv-2.dll") FileInstall("libiconv\UTF-8_BOM.cmd", $libiconvpath & "\UTF-8_BOM.cmd") FileInstall("libiconv\UTF-8_BOM.txt", $libiconvpath & "\UTF-8_BOM.txt") #Region ### START Koda GUI section ### Form= $form1 = GUICreate("Ïðåäâàðèòåëüíàÿ íàñòðîéêà óñòàíîâêè Windows 7 (64-bit)", 457, 177, -1, -1, BitOr($WS_CAPTION, $WS_POPUP)) $group1 = GUICtrlCreateGroup("Ïîëüçîâàòåëü", 8, 8, 217, 117) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $label1 = GUICtrlCreateLabel("Èìÿ ïîëüçîâàòåëÿ (åãî ïàïêè):", 16, 24, 165, 16) $name = GUICtrlCreateInput("Electric", 16, 44, 200, 21) $label2 = GUICtrlCreateLabel("Îòîáðàæàåìîå èìÿ ïîëüçîâàòåëÿ:", 16, 78, 184, 17) $displayname = GUICtrlCreateInput("Ýëåêòðèê", 14, 96, 201, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $rec = GUICtrlCreateButton("Âîññòàíîâëåíèèå", 232, 142, 110, 25) GUICtrlSetTip(-1, "Çàïóñòèòü ñðåäó âîññòàíîâëåíèÿ Windows 10 (64-bit).") $run = GUICtrlCreateButton("Óñòàíîâêà >>>", 350, 142, 100, 25) GUICtrlSetTip(-1, "Íà÷àòü óñòàíîâêó Windows 7 (64-bit). Îñòàëüíûå ïàðàìåòðû" & @CRLF & "óñòàíàâëèâàþòñÿ àâòîìàòè÷åñêè (êðîìå ðàçìåòêè äèñêà).") GUICtrlCreateGroup("", -99, -99, 1, 1) $group3 = GUICtrlCreateGroup("Èäåíòèôèêàöèÿ", 232, 8, 216, 117) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $randomcomp = GUICtrlCreateCheckbox("Ñëó÷àéíîå", 360, 24, 73, 15) GUICtrlSetState(-1, $gui_checked) $compname = GUICtrlCreateInput("*", 240, 44, 200, 21) $label7 = GUICtrlCreateLabel("Èìÿ êîìïüþòåðà:", 240, 24, 98, 16) $label8 = GUICtrlCreateLabel("Ðàáî÷àÿ ãðóïïà:", 240, 78, 89, 17) $workgroup = GUICtrlCreateInput("Home", 240, 96, 200, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $status = GUICtrlCreateLabel("", 14, 146, 185, 15, $ss_center) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 32896) $group4 = GUICtrlCreateGroup("", -24, 126, 529, 9) GUICtrlSetBkColor(-1, 0) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### If _ischecked($randomcomp) Then GUICtrlSetState($compname, $gui_disable) GUIRegisterMsg($wm_command, "WM_COMMAND") GUICtrlSetTip($name, 'Çàïðåùåíû ñèìâîëû " / \ [ ] : ; | = , + * ? < >') GUICtrlSetTip($compname, 'Çàïðåùåíû ñèìâîëû "' & " { | } ~ [ \ ] ^ ' : ; < = > ? @ ! # $ % ` ( ) + / . , *" & @CRLF & "è ïðîáåëû") GUICtrlSetTip($workgroup, 'Çàïðåùåíû ñèìâîëû " \ / : * ? < > |') Global $stext Global $dataerror = 0 Global $isearch1 = "" Global $isearch2 = "" Global $isearch3 = "" While 1 $nmsg = GUIGetMsg() Switch $nmsg Case $gui_event_close Exit Case $rec GUISetState(@SW_HIDE, $Form1) RunWait("X:\Sources\Recovery\RecEnv.exe") GUISetState(@SW_SHOW, $Form1) Case $randomcomp If _ischecked($randomcomp) Then GUICtrlSetState($compname, $gui_disable) GUICtrlSetData($compname, "*") Else GUICtrlSetState($compname, $gui_enable) GUICtrlSetData($compname, GUICtrlRead($name) & "-PC") EndIf Case $run If GUICtrlRead($compname) = GUICtrlRead($name) Then MsgBox(48, "", "Èìÿ ïîëüçîâàòåëÿ è èìÿ êîìüþòåðà íå äîëæíû ñîâïàäàòü", "", $form1) Else If $dataerror = 0 Then go() EndIf EndSwitch WEnd Func wm_command($hwnd, $imsg, $iwparam, $ilparam) Local $nnotifycode, $nid, $stext $nnotifycode = BitShift($iwparam, 16) $nid = BitAND($iwparam, 65535) Switch $hwnd Case $form1 Switch $nid Case $name Switch $nnotifycode Case $en_change $stext = GUICtrlRead($name) GUICtrlSetData($displayname, $stext) EndSwitch checkname() checkcompname() checkworkgroup() Case $compname Switch $nnotifycode Case $en_change EndSwitch checkname() checkcompname() checkworkgroup() Case $workgroup Switch $nnotifycode Case $en_change EndSwitch checkname() checkcompname() checkworkgroup() EndSwitch EndSwitch Return $gui_rundefmsg EndFunc Func checkname() Dim $arrayname[15] = ['"', "/", "\", "[", "]", ":", ";", "|", "=", ",", "+", "*", "?", "<", ">"] $sstring = GUICtrlRead($name) For $i = 0 To 14 $isearch1 = StringInStr($sstring, $arrayname[$i], 0) If $isearch1 <> 0 Then ExitLoop Next GUICtrlSetData($name, StringStripWS(GUICtrlRead($name), 1)) If $isearch1 <> "" Then GUICtrlSetData($status, "Íåäîïóñòèìûå ñèìâîëû") GUICtrlSetColor($status, 8388608) GUICtrlSetColor($name, 16711680) $dataerror = 1 Else GUICtrlSetColor($name, 0) status() EndIf EndFunc Func checkcompname() Dim $arraycompname[29] = [" ", '"', "{", "|", "}", "~", "[", "\", "]", "^", "'", ":", ";", "<", "=", ">", "?", "@", "!", "#", "$", "%", "`", "(", ")", "+", "/", ".", ","] $sstring = GUICtrlRead($compname) For $i = 0 To 28 $isearch2 = StringInStr($sstring, $arraycompname[$i], 0) If $isearch2 <> 0 Then ExitLoop Next GUICtrlSetData($compname, StringStripWS(GUICtrlRead($compname), 8)) If $isearch2 <> "" Then GUICtrlSetData($status, "Íåäîïóñòèìûå ñèìâîëû") GUICtrlSetColor($status, 8388608) GUICtrlSetColor($compname, 16711680) $dataerror = 1 Else GUICtrlSetColor($compname, 0) EndIf EndFunc Func checkworkgroup() Dim $arrayworkgroup[9] = ['"', "\", "/", ":", "*", "?", "<", ">", "|"] $sstring = GUICtrlRead($workgroup) For $i = 0 To 8 $isearch3 = StringInStr($sstring, $arrayworkgroup[$i], 0) If $isearch3 <> 0 Then ExitLoop Next GUICtrlSetData($workgroup, StringStripWS(GUICtrlRead($workgroup), 1)) If $isearch3 <> "" Then GUICtrlSetData($status, "Íåäîïóñòèìûå ñèìâîëû") GUICtrlSetColor($status, 8388608) GUICtrlSetColor($workgroup, 16711680) $dataerror = 1 Else GUICtrlSetColor($workgroup, 0) EndIf EndFunc Func status() If GUICtrlRead($compname) = "" OR GUICtrlRead($workgroup) = "" OR GUICtrlRead($name) = "" Then GUICtrlSetData($status, "Çàïîëíèòå ïóñòûå ïîëÿ") GUICtrlSetColor($status, 8388608) $dataerror = 1 Else If NOT $isearch1 <> "" OR $isearch2 <> "" OR $isearch3 <> "" Then GUICtrlSetData($status, "Äàííûå çàïîëíåíû âåðíî") GUICtrlSetColor($status, 32896) $dataerror = 0 EndIf EndIf EndFunc Func replace($s, $text) $stext = StringRegExpReplace($stext, "<(?i)" & $s & ">(.*?)</(?i)" & $s & ">", "<" & $s & ">" & $text & "</" & $s & ">") EndFunc Func _ischecked($control) Return BitAND(GUICtrlRead($control), $gui_checked) = $gui_checked EndFunc Func filescheck() Local $notexists If NOT FileExists($ipath & "\" & $xmlname) Then Local $notexists = @CRLF & $xmlname MsgBox(0, "Íåîáõîäèìûå ôàéëû", "Íå íàéäåí ôàéë, íåîáõîäèìûé äëÿ àâòîóñòàíîâêè:" & @CRLF & $notexists) Exit EndIf EndFunc Func go() GUISetState(@SW_HIDE, $form1) FileCopy($ipath & "\" & $xmlname, $opath, 9) $hfile = FileOpen($opath & "\" & $xmlname, 0) Global $stext = FileRead($hfile) FileClose($hfile) replace("Name", StringStripWS(GUICtrlRead($name), 3)) replace("DisplayName", StringStripWS(GUICtrlRead($displayname), 3)) replace("Username", GUICtrlRead($name)) replace("ComputerName", GUICtrlRead($compname)) replace("JoinWorkgroup", StringStripWS(GUICtrlRead($workgroup), 3)) $hfile = FileOpen($opath & "\" & $xmlname, 2) $stext = FileWrite($hfile, $stext) FileClose($hfile) RunWait(@ComSpec & " /c " & $libiconvpath & "\UTF-8_BOM.cmd" & $opath, "", @SW_HIDE, 2) #cs RunWait("x:\setup.exe /unattend:" & $opath & "\Unattend.xml") #ce GUISetState(@SW_SHOW, $Form1) Exit EndFunc |