Hallo Zusammen
Bin seit einiger Zeit an diesem Script, dennoch ist mein Know-how noch nicht ganz fortgeschritten.
gerne möchte ich hier mein momentanes Problem beheben.
"Der Button Wiederherstellung muss mehrmals gedrückt werden damit die Anwendung weiter geht."
- Währe offen für Verbesserungen
- Programmiertechnische Korrekturen.
Danke euch vilemals
MC
Spoiler anzeigen
;#-> MC - 02.04.2009 ------------------------------------------------------------------
;
; AutoIt Version : 3.3.0.0
; Author : Maurizio Caloro
;
; Programm Namwe : Restore @ Now
; Script Version : 1.0
;
; Script : Globalfunktion
; Laptop Images Restore
;
; Funktionen :
; IP Adressierung überprüfen
; Pfad auwertung von config.txt
; Netzwerkverbindung erstellen
; Laptop auswahl
; Laptop MAC-adressierung überprüfung
; Externe Anwendung für Restore zurücksicherung
; Temporäre Logfiles auf RamDrive erstellen
;
;#-> MC ----------------------------------------------------------------------------
#include <array.au3>
#include <file.au3>
#include <GUIConstantsEx.au3>
#include <Constants.au3>
Opt('MustDeclareVars', 1)
Core()
Func Core()
Local $aboutitem, $helpmenu, $runnow, $msg, $cfgfile, $path, $info, $speedview, $language, $laptop
Local $file, $cfgfile, $filelist, $exititem, $section, $config, $list, $pic, $cpu, $os, $office, $nMsg
Local $result_laptop, $result_os, $result_office, $result_language
;/ MAC TEIL
Local $filename, $found, $array, $text, $macs, $section1
;FileRead
$config = FileOpen("x:\programs\imager\config.txt", 0)
$path = FileReadLine($config)
FileClose($config)
;Drive Connect
DriveMapAdd("r:", ""& $path &"", 0, "kkl-luzern\VAT.LaptopRestore", "DABuAWbzRd4VL")
;NetworkCheck
If StringRegExpReplace(@IPAddress1, '(.+)\..+', '$1') = '10.1.0' Then
;MsgBox(1,"", "Correct")
Else
MsgBox(1,"Achtung", "Sie sind nicht mit dem korrekten Netzwerk verbunden." & Chr(10) & _
"Überprüfen Sie das Netzwerkkabel und versuchen Sie es nochmals.")
;SplashTextOn("--> ! Achtung ! < --", "Sie sind nicht mit dem korrekten Netzwerk verbunden."& CHR(10) & CHR(10) & _
; "Überprüfen Sie das Netzwerkkabel und versuchen Sie es nochmals.", 580, 100, -1, -1, 0, 0, 14)
; Sleep(10000)
;SplashOff()
Exit
EndIf
;Laptop.ini Config fileCheck
If FileExists("r:\laptop.ini") Then
ProgressOn("Die Anwendung", "-> 'Restore @ Now' wird Initialisiert.", "0 %")
For $i = 10 to 100 step 10
;sleep(1500)
sleep(1)
ProgressSet( $i, $i & " %")
Next
ProgressSet(100 , "Erstellt", "Start")
sleep(150)
ProgressOff()
;SplashTextOn("Vorbereitung", "Die Anwendung 'Restore @ Now' wird Initialisiert.", 440, 50, -1, -1, 0, 0, 14)
; Sleep(5000)
;SplashOff()
Else
MsgBox(16, "Netzwerkkabel", "Kein Laufwerk gefunden" & @CRLF & @CRLF & _
"Überprüfen Sie das Netzwerkkabel und" & @CRLF & _
"starten Sie gegebenenfalls den Laptop neu" & @CRLF & @CRLF & _
"Die Anwendung 'Restore @ Now' wird hiermit beendet!")
Exit
EndIf
GUICreate("Restore @ Now", 260, 340) ; Fenster Balken
;$pic = GUICtrlCreatePic ('x:\programs\imager\kkl.bmp',145 ,93 ,100 ,70)
$pic = GUICtrlCreatePic ('x:\kkl.bmp',145 ,238 ,105 ,70)
$filelist = GUICtrlCreateMenu("&File")
$exititem = GUICtrlCreateMenuItem("Exit", $filelist)
$helpmenu = GUICtrlCreateMenu("&?")
$info = GUICtrlCreateMenuItem("&Info", $helpmenu)
$aboutitem = GUICtrlCreateMenuItem("&About", $helpmenu)
;$font = "Arial"
GUISetFont(11, 400, 3) ; Font
;GUISetFont(11, 400, 3, $font) ; Font
;GUICtrlCreateLabel("Wählen Sie im nachfolgenden Software aufbau Ihre passende konfiguration", 8, 20)
GUICtrlCreateLabel("Ihr Laptop Modell ", 11, 20)
$laptop = GUICtrlCreateCombo("", 10, 42)
$section = IniReadSection("r:\laptop.ini", "Modell")
For $i = 1 To UBound($section) - 1
GUICtrlSetData($laptop, IniRead("r:\laptop.ini", "modell", $i, ""))
[/autoit] [autoit][/autoit] [autoit]Next
GUICtrlCreateLabel("Ihr Betriebssystem ", 11, 80)
$os = GUICtrlCreateCombo("", 10, 102)
$section = IniReadSection("r:\laptop.ini", "Os")
For $i = 1 To UBound($section) - 1
[/autoit] [autoit][/autoit] [autoit]GUICtrlSetData($os, IniRead("r:\laptop.ini", "Os", $i, ""))
[/autoit] [autoit][/autoit] [autoit]Next
GUICtrlCreateLabel("Ihr Office ", 11, 140)
$office = GUICtrlCreateCombo("", 10, 162)
$section = IniReadSection("r:\laptop.ini", "Office")
For $i = 1 To UBound($section) - 1
GUICtrlSetData($office, IniRead("r:\laptop.ini", "Office", $i, ""))
[/autoit] [autoit][/autoit] [autoit]Next
GUICtrlCreateLabel("Ihre Sprache ", 11, 200)
$language = GUICtrlCreateCombo("", 10, 222)
$section = IniReadSection("r:\laptop.ini", "Language")
For $i = 1 To UBound($section) - 1
GUICtrlSetData($language, IniRead("r:\laptop.ini", "Language", $i, ""))
[/autoit] [autoit][/autoit] [autoit]Next
$runnow = GUICtrlCreateButton("Wiederherstellen", 11, 268, 120)
;GUICtrlSetState(-1, $GUI_FOCUS) ; the focus is on this button
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $runnnow
If GUICtrlRead($Input1) And GUICtrlRead($Input2) And GUICtrlRead($Input2) Then
msgbox(0,"","Weiter")
Else
msgbox(0,"","Bitte alle felder ausfüllen")
EndIf
EndSwitch
WEnd
Do
;While 1
$msg = GUIGetMsg()
Switch $msg
;Case $exititem
Case $aboutitem
MsgBox(64, "Über - Restore @ Now", ""&Chr(10)& _
"E1"&Chr(10)& _
"6"&Chr(10)&Chr(10)& _
"Copyright 2009 "&Chr(10)& _
"Version 1.0"&Chr(10)&Chr(10)& _
"Ma"&Chr(10)& _
"Such",
Case $info
$cpu=Run('cpu.exe /s', "", @SW_HIDE,$STDOUT_CHILD)
While 1
sleep(250)
$speedview=StdoutRead($cpu)
If @error Then ExitLoop
MsgBox(64,"SYSINFO", "Computername "& @Computername &"" & CHR(10) & _
"Adressierung "& @IPAddress1 &"" & CHR(10) & _
"Betriebssystem "& @OSVersion &"" & CHR(10) & _
"Windows-Verzeichnis "& @Windowsdir &"" & CHR(10) & _
"Prozessor-Arch "& @CPUArch &"" & CHR(10) & _
"Prozessor-Typ "& $speedview)
Wend
Case $exititem
Exit
EndSwitch
;---------------------------------------------------------------------------------------->>>>
;About Darstellungsanpassung
;
;Example2()
;Func Example2()
; Local $gui
; $gui = GUICreate("About - Restore @ Now", 250, 400)
; GUISetState($WS_EX_LAYERED)
; ;$hWnd = GUICreate ('Test')
; $idBtn = GUICtrlCreatePic ('KKL.jpg', 20, 20)
; GUISetFont(13, 400, 1, $font)
; GUICtrlCreateLabel("t AG" & Chr(10) & _
; "1" & Chr(10) & _
; "6"& Chr(10) & Chr(10) & _
; "Cop" & Chr(10) & _
; "M" & Chr(10) & _
; "V", 10, 180, 320)
; GUISetFont(14, 400, 1, $font)
; GUICtrlCreateLabel("", 20, 200, 330)
; GUISetState ($WS_EX_LAYERED)
;EndFunc
; While True
; Switch GUIGetMsg ()
; Case -3
; Exit
; Case $idBtn
; MsgBox (266304, 'Test', 'Der Button wurde gedrückt ...')
; EndSwitch
; WEnd
;---------------------------------------------------------------------------------------->>>>
StringInStr(@IPAddress1, "2.")
If $msg = $runnow Then
[/autoit] [autoit][/autoit] [autoit]; START MAC
$filename = "b:\ipconfig.txt"
;MsgBox(64, "Info", "Laptop Model: " & GUICtrlRead($laptop) & Chr(10) & _
;"IP-Adresse: " & @IPAddress1 & Chr(10) & Chr(10) & _
;"Klicken Sie < OK > zum Starten der Wiederherstellung ")
;& Chr(10) & _ "Klicken Sie < Abbrechen > zum Abbrechen der Anwendung")
; Mit ipconfig Mac auslesen
RunWait(@ComSpec & " /c ipconfig /all > " & $filename, "", @SW_HIDE)
Dim $array
_FileReadToArray($filename, $array)
$text = _ArrayToString($array, ";")
$result_laptop = IniRead("r:\laptop.ini", "Result_Laptop",""&GuiCtrlRead($laptop)&"", "")
$result_os = IniRead("r:\laptop.ini", "Result_Os",""&GuiCtrlRead($os)&"", "")
$result_office = IniRead("r:\laptop.ini", "Result_Office",""&GuiCtrlRead($office)&"", "")
$result_language = IniRead("r:\laptop.ini", "Result_Language",""&GuiCtrlRead($language)&"", "")
MsgBox(4096, "Result", $result_laptop&$result_os&$result_office&$result_language)
MsgBox(1, "", GUICtrlRead($laptop)) ; uberprüfung des gewählten laptop
;MsgBox(1, "", GUICtrlRead($laptop)&GUICtrlRead($os)&GUICtrlRead($office)&GUICtrlRead($language)) ; uberprüfung des gewählten laptop
;MsgBox(1, "", GUICtrlRead($laptop)) ; uberprüfung des gewählten laptop
;$section1 = IniReadSection("r:\laptop.ini", ""&GuiCtrlRead($laptop)&"" )
$section1 = IniReadSection("r:\laptop.ini", ""&GuiCtrlRead($laptop)&"" )
;$section1 = IniReadSection("r:\laptop.ini", ""&GuiCtrlRead($laptop)&"" )
If @error Then
MsgBox(4096, "Kein Laufwerk "&GUICtrlRead($laptop), _
"Es ist ein Fehler aufgetreten. Wahrscheinlich keine INI Datei vorhanden.")
Else
;_ArrayDisplay($section1)
EndIf
$macs = StringRegExp($text, "(..-..-..-..-..-..)", 3)
;_ArrayDisplay($macs)
For $y = 1 To UBound($section1) - 1
For $j = 0 To UBound($macs) - 1
If $section1[$y][1] = $macs[$j] Then
$found = $macs[$j]
ExitLoop
EndIf
Next
Next
; Ausgabe
If $found <> "" Then
;SplashTextOn("MAC-AdresseCheck", "Ihre MAC-Adresse wurde erkannt (" & $found & ") Die Rücksicherung wird gestartet.", 722, 50, -1, -1, 0, 0, 12)
Sleep(50)
;SplashOff()
Else
MsgBox(0, "Autorisierung fehlgeschlagen", "Es wurde kein registrierter Laptop gefunden."& CHR(10) & _
"Die Anwendung wird hiermit beendet."& CHR(10) & CHR(10) & _
"Bei weiteren Fragen wenden Sie sich an <[email='Support.it@kkl-luzern.ch'][/email]>.")
FileDelete($filename)
Exit
EndIf
; temporäre Datei löschen
FileDelete($filename)
; STOP MAC
If $msg = 2 Then Exit
Sleep(Random(1000, 3000))
[/autoit] [autoit][/autoit] [autoit]$cfgfile = FileOpen("b:\" & GUICtrlRead($laptop) & ".cfg", 1)
FileWriteLine($cfgfile, "; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *")
FileWriteLine($cfgfile, "; * -- Restorescript aus Laptop.ini | Zeit " & @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($laptop))
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, "spartwin.exe -r -f b:\" & GUICtrlRead($laptop) & ".cfg")
FileWriteLine($file, "x:\programs\imager\spartwin.exe -r -f b:\" & GUICtrlRead($laptop) & ".cfg")
FileClose($file)
Sleep(Random(1000, 1500))
RunWait("b:\Restoremenow.cmd", "", @SW_MAXIMIZE)
FileMove("b:\" & GUICtrlRead($laptop) & ".cfg", "b:\" & GUICtrlRead($laptop) & ".txt")
FileMove("b:\Restoremenow.cmd", "b:\Restoremenow.txt")
MsgBox(0, "Finish Restore", "Restore konnte erfolgreich installiert werden.")
Exit
EndIf
Until $msg = $GUI_EVENT_CLOSE
EndFunc
noch das passende INI file.
Spoiler anzeigen
[Modell]
1=Lenovo_Z60M
2=Lenovo_Z61M
3=IBM
4=ACER
[Os]
1=Windows_2000
2=WIndows_XP
3=Windows_7
[Office]
1=Office_2003
2=Office_2007
3=Office_2010
[Language]
1=German
2=Englisch
------------------------------------------------------------->>> MAC Adressfilterin
[Lenovo_Z60M]
KKLLuzern_1=00-16-36-0B-66-29
KKLLuzern_2=00-16-36-0B-63-9A
KKLLuzern_3=00-16-36-0B-65-CE
KKLLuzern_4=00-1B-24-3F-D4-B2
VMWARE-MAUR=00-0C-29-C2-1E-3F # Disable
------------------------------------------------------------->>> Result from Userselection
[Result_Laptop]
Lenovo_Z60M=Z60
Lenovo_Z61M=Z61
IBM=IBM
ACER=ACE
[Result_Os]
Windows_2000=W2k
WIndows_XP=wXP
Windows_7=W_7
[Result_Office]
Office_2003=O03
Office_2007=O07
Office_2010=O10
[Result_Language]
German=ger
Englisch=eng