Hallo maurice,
probiere es einmal so:
Spoiler anzeigen
#include <array.au3>
#include <file.au3>
#include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 1)
Example()
Func Example()
Local $aboutitem, $helpmenu, $n1, $n2, $msg, $font, $var, $cfgfile, $ip, $s
Local $file, $cfgfile, $filelist, $exititem, $section, $msgbox, $restore
;/ MAC TEIL
Local $filename, $source_filename, $found, $array, $text, $macs, $filearray, $y, $j, $section1
GUICreate("Info Fenster - Restore now", 300, 300) ; Fenster Balken
[/autoit] [autoit][/autoit] [autoit]$filelist = GUICtrlCreateMenu("&File")
$exititem = GUICtrlCreateMenuItem("Exit", $filelist)
$helpmenu = GUICtrlCreateMenu("&?")
$aboutitem = GUICtrlCreateMenuItem("&About", $helpmenu)
$font = "Arial"
GUISetFont(11, 400, 3, $font) ; Font
GUICtrlCreateLabel("Wählen Sie das passende Image", 11, 30)
$n1 = GUICtrlCreateCombo("", 10, 50)
[/autoit] [autoit][/autoit] [autoit]$section = IniReadSection("laptop.ini", "section")
For $i = 1 To UBound($section) - 1
GUICtrlSetData($n1, IniRead("laptop.ini", "section", $i, ""))
Next
$n2 = GUICtrlCreateButton("Wiederherstellen", 10, 110, 120)
[/autoit] [autoit][/autoit] [autoit];DriveMapAdd("r:", "\\xyz\e$\xyz\Data\images\PC_laptops\laptop vat", 0, "login", "") ;<=====================
[/autoit] [autoit][/autoit] [autoit]GUICtrlSetState(-1, $GUI_FOCUS) ; the focus is on this button
GUISetState()
Do
$msg = GUIGetMsg()
Switch $msg
;Case $exititem
Case $aboutitem
GUISetFont(14, 400, 1, $font)
GUICtrlCreateLabel("" & Chr(10) & Chr(10) & "" & Chr(10) & "Version 0.5", 10, 180, 320)
Case $exititem
;Case $exititem, $GUI_EVENT_CLOSE
Exit
EndSwitch
;ExitLoop
$ip = StringInStr(@IPAddress1, "192.168")
$msg = GUIGetMsg()
If $msg = $n2 Then
$msgbox = MsgBox(1, "Achtung !", "Das Laptop model lautet: " & GUICtrlRead($n1) & Chr(10) & "Die zugewiesene IP-Adresse lautet: " & @IPAddress1 & Chr(10) & Chr(10) & "Klicken Sie < OK > zum Starten der Wiederherstellung " & Chr(10) & "Klicken Sie < Abbrechen > zum Abbrechen der Auswahl") ; anzeige gewähltes Image
; START MAC
$filename = "ipconfig.txt"
; mit ipconfig Mac auslesen
[/autoit] [autoit][/autoit] [autoit]RunWait(@ComSpec & " /c ipconfig /all > " & $filename, "", @SW_HIDE)
Dim $array
_FileReadToArray($filename, $array)
$text = _ArrayToString($array, ";")
MsgBox(1, "", GUICtrlRead($n1)) ; uberprüfung des gewählten laptop
$section1 = IniReadSection("laptop.ini", ""&GuiCtrlRead($n1)&"" )
If @error Then
MsgBox(4096, "Laptop: " & GUICtrlRead($n1), "Es ist ein Fehler aufgetreten. Warscheinlich keine INI Datei vorhanden.")
Else
_ArrayDisplay($section1)
;For $z=1 To UBound($section1)-1
; msgbox(1, "", $z) ; Only for TEST
;Next
EndIf ; <================= bis hier ist alles in Ordnung
$macs = StringRegExp($text, "(..-..-..-..-..-..)", 3)
;MsgBox(1, "Mac-Adresse", $text)
_ArrayDisplay($macs)
;Dim $filearray
;<============= von hier
For $y = 1 To UBound($section1) - 1
For $j = 0 To UBound($macs) - 1
; If StringInStr($section1[$y], $macs[$j]) Then
If $section1[$y][1] = $macs[$j] Then
$found = $macs[$j]
ExitLoop
EndIf
Next
Next
;<=============== bis hier
; Ausgabe
If $found <> "" Then
MsgBox(0, "MAC-Adresse gefunden", "Ihre MAC-Adresse wurde gefunden (" & $found & ")")
Else
MsgBox(0, "MAC-Adresse nicht gefunden", "Ihre MAC-Adresse wurde nicht gefunden.")
FileDelete($filename)
Exit
EndIf
; temporäre Datei löschen
FileDelete($filename)
; STOP MAC
If $msgbox = 2 Then Exit
[/autoit] [autoit][/autoit] [autoit]DriveMapAdd("r:", "\\xyz\e$\xyz\Data\images\PC_laptops\laptop vat", 0, "login", "")
Sleep(Random(1000, 3000))
$cfgfile = FileOpen("b:\" & GUICtrlRead($n1) & ".cfg", 1)
FileWriteLine($cfgfile, "; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *")
FileWriteLine($cfgfile, "; * -- Restore Script for Laptop.ini | Time " & @HOUR & ":" & @MIN & ":" & @SEC & " ---> Datum " & @MDAY & "." & @MON & "." & @YEAR & " -- *")
FileWriteLine($cfgfile, "; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *")
FileWriteLine($cfgfile, "mouse=no")
FileWriteLine($cfgfile, "filesystem=ntfs")
FileWriteLine($cfgfile, "disk=0")
FileWriteLine($cfgfile, "main_part=1")
FileWriteLine($cfgfile, "def_level=6")
FileWriteLine($cfgfile, "quit=nobadsector")
FileWriteLine($cfgfile, "automatic_naming=yes")
FileWriteLine($cfgfile, "file=r:\" & GUICtrlRead($n1))
FileClose($cfgfile)
Sleep(Random(1000, 2000))
$file = FileOpen("b:\Restoremenow.cmd", 1)
FileWriteLine($file, "REM * * * * * * * * * * * * * * * * * * * * * * *")
FileWriteLine($file, "REM * --- Zeit " & @HOUR & ":" & @MIN & ":" & @SEC & " -> Datum " & @MDAY & "." & @MON & "." & @YEAR & " --- *")
FileWriteLine($file, "REM * * * * * * * * * * * * * * * * * * * * * * *")
FileWriteLine($file, "x:\programs\imager\spartwin.ex_e -r -f b:\" & GUICtrlRead($n1) & ".cfg")
FileClose($file)
[/autoit] [autoit][/autoit] [autoit]Sleep(Random(1000, 2000))
[/autoit] [autoit][/autoit] [autoit]RunWait("b:\Restoremenow.cmd", "", @SW_MAXIMIZE)
[/autoit] [autoit][/autoit] [autoit];Run("b:\Restoremenow.cmd", "", @SW_MAXIMIZE)
FileMove("b:\" & GUICtrlRead($n1) & ".cfg", "b:\" & GUICtrlRead($n1) & ".txt")
FileMove("b:\Restoremenow.cmd", "b:\Restoremenow.txt")
MsgBox(0, "Finish Restore", "Restore konnte erfolgreich zurück gesichert werden.")
Exit
;FileDelete("b:\Restoremenow.cmd")
;DriveMapDel("r:")
EndIf
Until $msg = $GUI_EVENT_CLOSE
EndFunc ;==>Example
Stellen an denen ich wichtige Änderungen vorgenommen habe sind mit ;<========== gekennzeichnet
Viel Spass damit,
mfg (Auto)Bert