So hier nun der Angeküngite erste Release von Hephaistos. Hier nochmal die Beschreibung dazu aus dem Entwicklungsthread:
Spoiler anzeigen
Hallo,
ich möchte euch kurz etwas vorstellen an dem ich bereits seit Anfang Juli arbeite und es nun auch bereits auf über 60 Rechnern erfolgreich im Einsatz habe.
Es geht um ein von mir auf Hephaistos getaufte Softwareverteilung die vollkommen über Autoit realisiert wurde.
Der Grund warum ich eine Eigenentwicklung gemacht habe und nicht ein bereits fertiges Produkt genommen habe lässt sich in drei Punkten darlegen:
- Die meisten Softwareverteilungen kosten extrem viel und haben mehr Funktionen als ich brauche.
- Ein Großteil benötigt zwingt eine ADS wodurch z.B. Laptops die nicht in der ADS sind aber im gleichen Netzwerk nicht versorgt werden können.
- Bei vielen werden Router im Netzwerk nicht unterstützt.
Aus diesen Gründen ist Hephaistos entstanden.
Es ist eine Client-Server-Anwendung die es ermöglicht Autoitscirpte oder auch sonstige Automatisierungen wie MSI auf Rechner zu installieren.
Auf den Clients muss lediglich eine install.exe ausgeführt werden die dann die aktuelle Version der Clientsoftware auf den Rechner installiert. Bei jedem Anmelden an dem Rechner wird geprüft ob eine neuere Version der Clientsoftware verfügbar ist und wenn ja wir diese im Hintergrund installiert. Von diese Aktualisierung bekommt der Benutzer nichts mit was es ermöglich auch im laufenden Alltagsbetrieb neue Versionen des Clients zu verteilen.
Die Clients melden sich nach der Anmeldung beim Server und falls sie dort noch nicht bekannt sind landen sie in einer neutralen Gruppe. Der Rechner wird unter anderem Anhang seine MAC Identifiziert wodurch es auch ohne Probleme möglich ist den Namen eines Rechners zu ändern ohne das es Probleme mit der Installierten Software gibt.
Es können beliebig viele Gruppen, denen Rechner zugewiesen werden, erstellt werden. Software kann sowohl Gruppen als auch nur einzelnen Rechner zugewiesen werden.
Die zu verteilenden Software wird automatisch durch die Adminkonsole erkannt. Wobei hier ebenfalls automatisch darauf hingewiesen wir ob nur ein Installations- oder nur eine Deinstallationscript vorhanden ist. Oder eben auch ob man es sowohl deinstallieren auch als installieren kann oder keines von beidem. Das ganze wird durch eindeutige Icons vor den Namen der Programme angezeigt und ist sofort auf einen Blick überschaubar.
Es ist auch möglich einzelnen Rechner oder ganze Gruppen Herunterzufahren, Neuzustarten oder Aufzuwecken.
Es ist auch Möglich zu aktivieren das nach dem Neustart der Rechner ein bestimmter Account automatisch eingeloggt wird. Allerdings ist das ein Punkt der leider nur unschön über die ADS zu lösen ist indem man dort ein entsprechendes Template hinterlegt dem man dann einen User zuweißt. Diese Funktion ist also nicht wirklich Massentauchglich.
Zurzeit bin ich noch dabei die Möglichkeit einzubauen das man Regeln definieren wie z.B. das wenn ein Programm zur Installation markiert ist ein anderes zwingend auch mit installiert werden muss usw.
Das ganze läuft zwar schon wie gesagt Erfolgreich auf über 60 Rechner und diese wurden auch komplett nur über Hephaistos mit Software versorgt aber es sind noch einige Ideen und Punkte die ich noch ändern will/muss.
Wie bei jeder Software braucht es erstmal ein klein wenig Arbeit zum einrichten aber danach ist die Verteilung/Aktuallisierung von Hepheistos zu 99% automatisch durchführbar. Es ist zu sagen das das ganze aktuell allerdings noch mit einigen RunAs Befehlen arbeiten in der auch die ADS benötigt wird von daher ist es nur bei vorhandensein einer ADS lauffähig (Wird noch geändert). Es muss allerdings nur der Rechner der als Server benutzt werden soll in einer ADS sein die Clientrechner müssen dies nicht!
So hier nun die Anleitung zur Serverinstallation:
1. Erstellt auf dem Rechner der als Server arbeiten soll eine Netzwerkfreigabe auf einen Ordner
2. Erstellt einen Benutzer der Zugriff auf diese Freigabe und gleichzeitig auch Adminrechte auf den zu versorgenden Clients hat.
3. In das Freigabeverzeichniss kommen folgende Dateien (Achtung vorher die Variablen noch anpassen sonst geht nichts ;))
run.exe
Spoiler anzeigen
#cs ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]AutoIt Version: 3.3.0.0
Author: Kai Forstner (chip)
Copyright (C) 2010 Kai Forstner (chip)
[/autoit] [autoit][/autoit] [autoit]This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
[/autoit] [autoit][/autoit] [autoit]This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
[/autoit] [autoit][/autoit] [autoit]You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>.
[/autoit] [autoit][/autoit] [autoit]#ce ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$admin = "admin"
$passwort = "adminpw"
$ads = "ads"
$clientinstall = "C:\Programme\install\"
RunAs($admin, $ads, $passwort, 1, $clientinstall & "client.exe")
[/autoit]
client.exe
Spoiler anzeigen
#cs ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]AutoIt Version: 3.3.0.0
Author: Kai Forstner (chip)
Copyright (C) 2010 Kai Forstner (chip)
[/autoit] [autoit][/autoit] [autoit]This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
[/autoit] [autoit][/autoit] [autoit]This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
[/autoit] [autoit][/autoit] [autoit]You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>.
[/autoit] [autoit][/autoit] [autoit]#ce ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <_GetIntersection.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$admin = "admin"
$passwort = "admin"
$ads = "ads"
$clientinstall = "C:\Programme\install\"
$serverip = "193.196.72.5"
$freigabe = "ProgrammeAutoit$"
$iWidth = @DesktopWidth
$iHeight = @DesktopHeight
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("", $iWidth, $iHeight, 0, 0, $WS_POPUP)
$Label1 = GUICtrlCreateLabel("", $iWidth / 2 - 200, $iHeight / 2 - 50, 400, 36, $SS_CENTER)
GUICtrlSetFont(-1, 20, 400, 0, "Arial")
$Progress1 = GUICtrlCreateProgress($iWidth / 2 - 150, $iHeight / 2 - 10, 300, 17)
GUISetState(@SW_HIDE)
#EndRegion ### END Koda GUI section ###
Func _GetMACFromIP($sIP = @IPAddress1, $mode = 1)
Local $MAC, $MACSize
Local $i, $s, $r, $iIP
$MAC = DllStructCreate("byte[6]")
$MACSize = DllStructCreate("int")
DllStructSetData($MACSize, 1, 6)
$r = DllCall("Ws2_32.dll", "int", "inet_addr", _
"str", $sIP)
$iIP = $r[0]
$r = DllCall("iphlpapi.dll", "int", "SendARP", "int", $iIP, "int", 0, "ptr", DllStructGetPtr($MAC), "ptr", DllStructGetPtr($MACSize))
$s = ""
If $mode = 0 Then
For $i = 0 To 5
$s &= Hex(DllStructGetData($MAC, 1, $i + 1), 2)
Next
ElseIf $mode = 1 Then
For $i = 0 To 5
If $i Then $s = $s & ":"
$s = $s & Hex(DllStructGetData($MAC, 1, $i + 1), 2)
Next
ElseIf $mode = 2 Then
For $i = 0 To 5
If $i Then $s = $s & "-"
$s = $s & Hex(DllStructGetData($MAC, 1, $i + 1), 2)
Next
EndIf
Return $s
EndFunc ;==>_GetMACFromIP
Do
Local $macadresse = ""
$macadresse = _GetMACFromIP()
Until $macadresse <> ""
$text = @IPAddress1 & "#" & $macadresse & "#" & @ComputerName
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$Empfaenger_IP = $serverip
$Port = 33891
TCPStartup()
$ConnectedSocket = TCPConnect($Empfaenger_IP, $Port)
$connecttimmer = 100
Do
$recv = TCPRecv($ConnectedSocket, 2048)
Sleep(100)
If $connecttimmer = 0 Then
Exit
EndIf
$connecttimmer = $connecttimmer - 1
Until $recv <> ""
BlockInput(1)
[/autoit] [autoit][/autoit] [autoit]TCPSend($ConnectedSocket, $text)
Sleep(2000)
TCPShutdown()
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]DriveMapAdd("X:", "\\" & $serverip & "\" & $freigabe, 8, $ads & "\" & $admin, $passwort)
[/autoit] [autoit][/autoit] [autoit]DriveMapGet("N:")
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$localini = IniRead($clientinstall & "client.ini", "Client", "Version", "0")
$remotini = IniRead("\\" & $serverip & "\" & $freigabe & "\client.ini", "Client", "Version", "0")
If $localini <> $remotini Then
$pid = RunAsWait($admin, $ads, $passwort, 0, "\\" & $serverip & "\" & $freigabe & "\install.exe")
EndIf
GUICtrlSetData($Progress1, 20)
GUICtrlSetData($Label1, "Software wird überprüft")
GUISetState(@SW_SHOW,$Form1)
$sSQliteDll = _SQLite_Startup()
$remotedb = _SQLite_Open('X:\datenbank.db')
Dim $Query = "", $Zeile = ""
_SQLite_Query($remotedb, "SELECT kategorie FROM Rechner WHERE mac = '" & $macadresse & "'", $Query)
While _SQLite_FetchData($Query, $Zeile) = $SqlITE_OK
For $element In $Zeile
Dim $programmQuery = "", $programmZeile = ""
_SQLite_Query($remotedb, "SELECT programmname FROM Zuweisenkategorie WHERE kategorie = '" & $element & "'", $programmQuery)
Dim $count = 0
Dim $programme[1]
While _SQLite_FetchData($programmQuery, $programmZeile) = $SqlITE_OK
For $programmelement In $programmZeile
ReDim $programme[$count + 1]
$programme[$count] = $programmelement
$count = $count + 1
Next
WEnd
Dim $programmQuery = "", $programmZeile = ""
_SQLite_Query($remotedb, "SELECT programmname FROM Zuweisenrechner WHERE rechnername = '" & @ComputerName & "'", $programmQuery)
While _SQLite_FetchData($programmQuery, $programmZeile) = $SqlITE_OK
For $programmelement In $programmZeile
ReDim $programme[$count + 1]
$programme[$count] = $programmelement
$count = $count + 1
Next
WEnd
Next
WEnd
_SQLite_Close($remotedb)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$localdb = _SQLite_Open($clientinstall & 'local.db')
[/autoit] [autoit][/autoit] [autoit]$strCREATE = _
"CREATE TABLE [Programme] (" & _
"[id] INTEGER PRIMARY KEY NOT NULL," & _
"[programmname] VARCHAR[50] NULL)"
If _SQLite_Exec($localdb, $strCREATE) <> $SqlITE_OK Then
EndIf
[/autoit] [autoit][/autoit] [autoit]Dim $localprogrammQuery = "", $localprogrammZeile = ""
_SQLite_Query($localdb, "SELECT programmname FROM Programme WHERE id > 0 ", $localprogrammQuery)
Dim $count = 0
Dim $localprogramme[1]
While _SQLite_FetchData($localprogrammQuery, $localprogrammZeile) = $SqlITE_OK
For $localprogrammelement In $localprogrammZeile
ReDim $localprogramme[$count + 1]
$localprogramme[$count] = $localprogrammelement
$count = $count + 1
Next
WEnd
_SQLite_Close($localdb)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Dim $install[1]
Dim $uninstall[2]
$ret = _GetIntersection($programme, $localprogramme, 0, ' ')
GUICtrlSetData($Progress1, 40)
GUICtrlSetData($Label1, "Software wird deinstalliert")
For $i = 0 To UBound($ret) - 1
If $ret[$i][2] <> '' Then
$pid = RunAsWait($admin, "ads", $passwort, 0, "\\" & $serverip & "\" & $freigabe & "\" & $ret[$i][2] & "\uninstall.exe")
ProcessWaitClose($pid)
$localdb = _SQLite_Open($clientinstall & 'local.db')
_SQLite_Exec(-1, "DELETE FROM Programme WHERE programmname = '" & $ret[$i][2] & "'")
_SQLite_Close($localdb)
EndIf
Next
GUICtrlSetData($Progress1, 80)
GUICtrlSetData($Label1, "Software wird installiert")
BlockInput(0)
For $i = 0 To UBound($ret) - 1
If $ret[$i][1] <> '' Then
$pid = RunAsWait($admin, "ads", $passwort, 0, "\\" & $serverip & "\" & $freigabe & "\" & $ret[$i][1] & "\install.exe")
ProcessWaitClose($pid)
$localdb = _SQLite_Open($clientinstall & 'local.db')
_SQLite_Exec(-1, "INSERT INTO Programme (id, programmname) VALUES (NULL, '" & $ret[$i][1] & "')")
_SQLite_Close($localdb)
EndIf
Next
BlockInput(1)
GUICtrlSetData($Progress1, 100)
GUICtrlSetData($Label1, "Aktuallisierung wird beendet")
_SQLite_Shutdown()
DriveMapDel("X:")
BlockInput(0)
scratch.bat
Spoiler anzeigen
client.ini
Spoiler anzeigen
[Client]
Version=1.1.7
Ich weiß ist bisschen Arbeit aber wie gesagt braucht ihr das nur einmal machen und dann nie wieder :).
4. Jetzt kommt das Herzstück, der eigentliche Server. Startet folgende Datei (Variablen anpassen nicht vergessen) auf dem Server.
Spoiler anzeigen
#cs ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]AutoIt Version: 3.3.0.0
Author: Kai Forstner (chip)
Copyright (C) 2010 Kai Forstner (chip)
[/autoit] [autoit][/autoit] [autoit]This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
[/autoit] [autoit][/autoit] [autoit]This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
[/autoit] [autoit][/autoit] [autoit]You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>.
[/autoit] [autoit][/autoit] [autoit]#ce ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]#include <SQLite.au3>
#include <SQLite.dll.au3>
$freigabe = "H:\Packages\ProgrammeAutoit\"
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Local $sSQliteDll
$sSQliteDll = _SQLite_Startup()
If @error > 0 Then
MsgBox(16, "SQLite Fehler", "SQLite.dll konnte nicht geladen werden!")
Exit -1
EndIf
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CR)
_SQLite_Open($freigabe & 'datenbank.db')
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$strCREATE = _
"CREATE TABLE [Rechner] (" & _
"[id] INTEGER PRIMARY KEY NOT NULL," & _
"[ip] VARCHAR[15]NULL," & _
"[mac] VARCHAR[17] NULL," & _
"[name] VARCHAR[50] NULL," & _
"[kategorie] VARCHAR[50] NULL)"
If _SQLite_Exec(-1, $strCREATE) <> $SQLITE_OK Then
EndIf
[/autoit] [autoit][/autoit] [autoit]$strCREATE = _
"CREATE TABLE [Zuweisenrechner] (" & _
"[id] INTEGER PRIMARY KEY NOT NULL," & _
"[programmname] VARCHAR[50] NULL," & _
"[rechnername] VARCHAR[50] NULL)"
If _SQLite_Exec(-1, $strCREATE) <> $SQLITE_OK Then
EndIf
[/autoit] [autoit][/autoit] [autoit]$strCREATE = _
"CREATE TABLE [Zuweisenkategorie] (" & _
"[id] INTEGER PRIMARY KEY NOT NULL," & _
"[programmname] VARCHAR[50] NULL," & _
"[kategorie] VARCHAR[50] NULL)"
If _SQLite_Exec(-1, $strCREATE) <> $SQLITE_OK Then
EndIf
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]_SQLite_Close()
_SQLite_Shutdown()
TCPStartup()
$MainSocket = TCPListen(@IPAddress1, 33891, 100)
While 1
[/autoit] [autoit][/autoit] [autoit]While 1
$ConnectedSocket = TCPAccept($MainSocket)
If $ConnectedSocket <> -1 Then ExitLoop
Sleep(100)
WEnd
TCPSend($ConnectedSocket, "1")
[/autoit] [autoit][/autoit] [autoit]Do
$recv = TCPRecv($ConnectedSocket, 2048)
Sleep(100)
Until $recv <> ""
_SQLite_Startup()
_SQLite_Open($freigabe & '\datenbank.db')
$empfang = StringSplit($recv, "#")
[/autoit] [autoit][/autoit] [autoit]Local $hQuery, $hZeile = ""
_SQLite_Query(-1, "SELECT ip,name FROM Rechner WHERE mac = '" & $empfang[2] & "'", $hQuery)
_SQLite_FetchData($hQuery, $hZeile)
_SQLite_QueryFinalize($hQuery)
$anzahl = UBound($hZeile)
[/autoit] [autoit][/autoit] [autoit]If $anzahl < 2 Then
_SQLite_Exec(-1, "INSERT INTO Rechner (id, ip, mac, name, kategorie) VALUES (NULL, '" & $empfang[1] & "', '" & $empfang[2] & "', '" & $empfang[3] & "', 'keine')")
Else
_SQLite_Exec(-1, "UPDATE Rechner SET ip = '" & $empfang[1] & "', name = '" & $empfang[3] & "' WHERE mac ='" & $empfang[2] & "'")
EndIf
_SQLite_Close()
_SQLite_Shutdown()
WEnd
TCPShutdown()
_SQLite_Close()
_SQLite_Shutdown()
So das wars der Server ist nun bereit und wartet auf Clients.
Die Clientinstallation:
Die Clientinstalltion ist recht einfach. Nach anpassen der Variablen einfach folgende Datei auf dem Client starten. Nach einem neuanmelden am Rechner ist er bereit zum Softwareerhalt. Ich persönlich habe die Datei einfach eimal compiliert und im Rohimage (das ich zum schnellen Rechnerinstallieren nutze) in den Autostart gelegt. Hat einfach den Vorteil das ein neue Rechner immer direkt auch soweit ist Software zu bekommen ohne das ich per Hand noch etwas machen muss. Durch die scratch.bat die wir in die Freigabe bei der Serverinstallation gelegt haben wird die isntall.exe dann auch wieder automatisch nach der installation aus dem Autostart genommen.
Spoiler anzeigen
#cs ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]AutoIt Version: 3.3.0.0
Author: Kai Forstner (chip)
Copyright (C) 2010 Kai Forstner (chip)
[/autoit] [autoit][/autoit] [autoit]This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
[/autoit] [autoit][/autoit] [autoit]This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
[/autoit] [autoit][/autoit] [autoit]You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>.
[/autoit] [autoit][/autoit] [autoit]#ce ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]$admin = "admin"
$passwort = "adminpw"
$ads = "ads"
$clientinstall = "C:\Programme\install\"
$serverip = "193.196.72.5"
$freigabe = "ProgrammeAutoit$"
$PID = ProcessExists("client.exe")
If $PID Then ProcessClose($PID)
DriveMapAdd("X:", "\\" & $serverip & "\" & $freigabe, 8, $ads & "\" & $admin, $passwort)
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Autoit", "REG_SZ", $clientinstall & "run.exe")
FileCopy("\\" & $serverip & "\" & $freigabe & "\run.exe", $clientinstall & "run.exe", 9)
FileCopy("\\" & $serverip & "\" & $freigabe & "\client.exe", $clientinstall & "client.exe", 9)
FileCopy("\\" & $serverip & "\" & $freigabe & "\scratch.bat", $clientinstall & "scratch.bat", 9)
FileCopy("\\" & $serverip & "\" & $freigabe & "\client.ini", $clientinstall & "client.ini", 9)
DriveMapDel("X:")
RunAs($admin, $ads, $passwort, 0, $clientinstall & "scratch.bat")
So das wars, der Sever läuft und die Clients sind bereit um Software zu erhalten. Doch nun werden sich wohl sicher einige Fragen wie man den nun die Software zuweist. Das geht recht einfach. Erstellt in der Freigabe für jedes Programm jeweils einen Ordner z.B. "Office 2007", "Adobe Reader" usw. In diese Ordner kommen nun die entsprechenden Setupdateien der Programme und euer Autoitinstallationsscript (Wie man so eines erstellt brauche ich wohl nicht erklären, sollte bekannt sein). Zu beachten ist lediglich das Script install.exe (bzw. wenn ihr es auch wieder deinstallieren wollt noch die datei uninstall.exe) zu nennen.
Nun könnt ihr über das Admininteface Rechner in Gruppen anordner, Software der ganzen Gruppen zuweißen, Software nur einzelnen Rechner zuweißen, Rechner neu starten usw.
Spoiler anzeigen
#cs ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]AutoIt Version: 3.3.0.0
Author: Kai Forstner (chip)
Copyright (C) 2010 Kai Forstner (chip)
[/autoit] [autoit][/autoit] [autoit]This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
[/autoit] [autoit][/autoit] [autoit]This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
[/autoit] [autoit][/autoit] [autoit]You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>.
[/autoit] [autoit][/autoit] [autoit]#ce ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]#NoTrayIcon
#include <File.au3>
#include <GuiComboBox.au3>
#include <GuiTreeView.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
$serverip = "193.196.72.5"
$freigabe = "ProgrammeAutoit$"
DriveMapAdd("X:", "\\" & $serverip & "\" & $freigabe)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]#Region ### START Koda GUI section ### Form=
$Form = GUICreate("Softwareverteilung Hephaistos", 985, 889, 167, 53)
$RechnerTreeView = GUICtrlCreateTreeView(8, 8, 353, 873, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKBOTTOM)
$Rechnername = GUICtrlCreateLabel("", 376, 16, 116, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
GUICtrlSetState(-1, $GUI_HIDE)
$Gruppe = GUICtrlCreateCombo("", 376, 48, 145, 25)
GUICtrlSetState(-1, $GUI_HIDE)
$Gruppeaendern = GUICtrlCreateButton("ändern", 528, 47, 75, 25, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$programmtree = GUICtrlCreateTreeView(384, 88, 329, 617, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES, $WS_GROUP, $WS_TABSTOP))
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM)
$nGruppe = GUICtrlCreateButton("neue Gruppe", 608, 47, 75, 25, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$Speichern = GUICtrlCreateButton("speichern", 720, 88, 75, 25, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$Pic1 = GUICtrlCreatePic("C:\Dokumente und Einstellungen\g-admin\Desktop\autoit3\loader.gif", 496, 288, 100, 100, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
GUICtrlSetState(-1, $GUI_HIDE)
$Rechnerneustart = GUICtrlCreateButton("Neustarten", 857, 77, 115, 25, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$Rechnerherunterfahren = GUICtrlCreateButton("Herunterfahren", 857, 107, 115, 25, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$Rechnerwakeup = GUICtrlCreateButton("Wakeup", 857, 47, 115, 25, 0)
GUISetState(@SW_SHOW, $Form)
#EndRegion ### END Koda GUI section ###
Func _dbopen()
Local $sSQliteDll
$sSQliteDll = _SQLite_Startup()
If @error > 0 Then
MsgBox(16, "SQLite Fehler", "SQLite.dll konnte nicht geladen werden!")
Exit -1
EndIf
_SQLite_Open('X:\datenbank.db')
EndFunc ;==>_dbopen
Func _dbclose()
_SQLite_Close()
_SQLite_Shutdown()
EndFunc ;==>_dbclose
Func _Programmliste($rechner, $typ)
$Programmliste = _FileListToArray("X:", "*", 2)
If @error = 1 Then
MsgBox(0, "", "Keine Programme gefunden")
$Programmliste[0] = 0
EndIf
Dim $Programmitem[1]
$x = 0
GUICtrlSetState($programmtree, $GUI_HIDE)
GUICtrlSetState($Pic1, $GUI_SHOW)
_GUICtrlTreeView_BeginUpdate($programmtree)
_GUICtrlTreeView_DeleteAll($programmtree)
$listcount = 0
For $element In $Programmliste
If $listcount > 0 Then
ReDim $Programmitem[$x + 1]
$Programmitem[$x] = _GUICtrlTreeView_Add($programmtree, 0, $element)
$uninstall = False
$install = False
If FileExists("\\" & $serverip & "\" & $freigabe & "\" & $element & "\uninstall.exe") Then
$uninstall = True
EndIf
If FileExists("\\" & $serverip & "\" & $freigabe & "\" & $element & "\install.exe") Then
$install = True
EndIf
If $install = False And $uninstall = False Then
_GUICtrlTreeView_SetIcon($programmtree, $Programmitem[$x], "shell32.dll", 27)
ElseIf $install = False Then
_GUICtrlTreeView_SetIcon($programmtree, $Programmitem[$x], "shell32.dll", 24)
ElseIf $uninstall = False Then
_GUICtrlTreeView_SetIcon($programmtree, $Programmitem[$x], "shell32.dll", 31)
Else
_GUICtrlTreeView_SetIcon($programmtree, $Programmitem[$x], "shell32.dll", 13)
EndIf
_dbopen()
Dim $programmlisteQuery = "", $programmlisteZeile = ""
If $typ = "rechner" Then
_SQLite_Query(-1, "SELECT id FROM Zuweisenrechner WHERE programmname = '" & $element & "' AND rechnername = '" & $rechner & "'", $programmlisteQuery)
Else
_SQLite_Query(-1, "SELECT id FROM Zuweisenkategorie WHERE programmname = '" & $element & "' AND kategorie = '" & $rechner & "'", $programmlisteQuery)
EndIf
While _SQLite_FetchData($programmlisteQuery, $programmlisteZeile) = $SqlITE_OK
For $programmlisteelement In $programmlisteZeile
_GUICtrlTreeView_SetChecked($programmtree, $Programmitem[$x])
Next
WEnd
_dbclose()
$x = $x + 1
Else
$listcount = 1
EndIf
Next
_GUICtrlTreeView_EndUpdate($programmtree)
GUICtrlSetState($programmtree, $GUI_SHOW)
GUICtrlSetState($Pic1, $GUI_HIDE)
Return $Programmitem
EndFunc ;==>_Programmliste
Func _Install($rechner, $programm)
Dim $id = $rechner
_dbopen()
Dim $installQuery = "", $installZeile = ""
_SQLite_Query(-1, "SELECT id FROM Rechner WHERE name = '" & $rechner & "'", $installQuery)
While _SQLite_FetchData($installQuery, $installZeile) = $SqlITE_OK
For $installelement In $installZeile
$id = $installelement
Next
WEnd
If $id > 0 Then
[/autoit] [autoit][/autoit] [autoit]_SQLite_Exec(-1, "INSERT INTO Zuweisenrechner(id, programmname, rechnername) VALUES (NULL, '" & $programm & "', '" & $rechner & "')")
[/autoit] [autoit][/autoit] [autoit]Else
_SQLite_Exec(-1, "INSERT INTO Zuweisenkategorie(id, programmname, kategorie) VALUES (NULL, '" & $programm & "', '" & $rechner & "')")
EndIf
_dbclose()
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]EndFunc ;==>_Install
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func _Gruppe($name)
Dim $wert
_dbopen()
Dim $poolQuery = "", $poolZeile = ""
_SQLite_Query(-1, "SELECT kategorie FROM Rechner WHERE name = '" & $name & "'", $poolQuery)
While _SQLite_FetchData($poolQuery, $poolZeile) = $SqlITE_OK
For $poolelement In $poolZeile
$wert = $poolelement
Next
WEnd
_dbclose()
Return $wert
EndFunc ;==>_Gruppe
Func _Rechnertreeviewupdate()
Dim $count = 2
Dim $rkategorie[1]
_GUICtrlTreeView_BeginUpdate($RechnerTreeView)
_GUICtrlTreeView_DeleteAll($RechnerTreeView)
GUICtrlSetData($Gruppe, "")
Dim $poolQuery = "", $poolZeile = ""
_SQLite_Query(-1, "SELECT kategorie FROM Rechner WHERE id > 0 GROUP BY kategorie", $poolQuery)
While _SQLite_FetchData($poolQuery, $poolZeile) = $SqlITE_OK
For $poolelement In $poolZeile
ReDim $rkategorie[$count + 1]
$rkategorie[$count] = $poolelement
_GUICtrlComboBox_AddString($Gruppe, $poolelement)
$topitem = _GUICtrlTreeView_Add($RechnerTreeView, 0, $poolelement)
Dim $rechnerQuery = "", $rechnerZeile = ""
_SQLite_Query(-1, "SELECT name FROM Rechner WHERE kategorie = '" & $poolelement & "'", $rechnerQuery)
While _SQLite_FetchData($rechnerQuery, $rechnerZeile) = $SqlITE_OK
For $rechnerelement In $rechnerZeile
_GUICtrlTreeView_AddChild($RechnerTreeView, $topitem, $rechnerelement)
Next
WEnd
$count = $count + 1
Next
WEnd
_GUICtrlTreeView_EndUpdate($RechnerTreeView)
Return $rkategorie
EndFunc ;==>_Rechnertreeviewupdate
Func _Rechnerneustart($typ, $name)
If $typ = "rechner" Then
RunWait(@ComSpec & " /c shutdown -r -f -m \\" & $name)
MsgBox(64, "Neustart", "Der Rechner " & $name & " wurde neu gestartet.", 2)
Else
_dbopen()
Dim $rechnerQuery = "", $rechnerZeile = ""
_SQLite_Query(-1, "SELECT name FROM Rechner WHERE kategorie = '" & $name & "'", $rechnerQuery)
While _SQLite_FetchData($rechnerQuery, $rechnerZeile) = $SqlITE_OK
For $rechnerelement In $rechnerZeile
RunWait(@ComSpec & " /c shutdown -r -f -m \\" & $rechnerelement)
Next
WEnd
_dbclose()
MsgBox(64, "Neustart", "Der Rechner der Gruppe " & $name & " wurden neu gestartet.", 2)
EndIf
EndFunc ;==>_Rechnerneustart
Func _Rechnerherunterfahren($typ, $name)
If $typ = "rechner" Then
RunWait(@ComSpec & " /c shutdown -s -f -m \\" & $name)
MsgBox(64, "Herunterfahren", "Der Rechner " & $name & " wurde heruntergefahren.", 2)
Else
_dbopen()
Dim $rechnerQuery = "", $rechnerZeile = ""
_SQLite_Query(-1, "SELECT name FROM Rechner WHERE kategorie = '" & $name & "'", $rechnerQuery)
While _SQLite_FetchData($rechnerQuery, $rechnerZeile) = $SqlITE_OK
For $rechnerelement In $rechnerZeile
RunWait(@ComSpec & " /c shutdown -s -f -m \\" & $rechnerelement)
Next
WEnd
_dbclose()
MsgBox(64, "Herunterfahren", "Der Rechner der Gruppe " & $name & " wurden heruntergefahren.", 2)
EndIf
EndFunc ;==>_Rechnerherunterfahren
Func _Rechnerwakeup($typ, $name)
If $typ = "rechner" Then
_dbopen()
Dim $rechnerQuery = "", $rechnerZeile = ""
_SQLite_Query(-1, "SELECT mac FROM Rechner WHERE name = '" & $name & "'", $rechnerQuery)
While _SQLite_FetchData($rechnerQuery, $rechnerZeile) = $SqlITE_OK
For $rechnerelement In $rechnerZeile
$mac = StringReplace($rechnerelement, ":", "-")
Dim $rechnerQuery = "", $rechnerZeile = ""
_SQLite_Query(-1, "SELECT ip FROM Rechner WHERE name = '" & $name & "'", $rechnerQuery)
While _SQLite_FetchData($rechnerQuery, $rechnerZeile) = $SqlITE_OK
For $rechnerelement In $rechnerZeile
$broad = StringSplit($rechnerelement, ".")
RunWait(@ComSpec & " /c " & '"' & @ScriptDir & "\wake.exe" & '"' & " " & $mac & " " & $broad[1] & "." & $broad[2] & "." & $broad[3] & ".255")
Next
WEnd
Next
WEnd
_dbclose()
MsgBox(64, "Wakeup", "Der Rechner " & $name & " wurde aufgeweckt.", 2)
Else
_dbopen()
Dim $rechnerQuery = "", $rechnerZeile = ""
_SQLite_Query(-1, "SELECT mac FROM Rechner WHERE kategorie = '" & $name & "'", $rechnerQuery)
While _SQLite_FetchData($rechnerQuery, $rechnerZeile) = $SqlITE_OK
For $rechnerelement In $rechnerZeile
$mac = StringReplace($rechnerelement, ":", "-")
Dim $wakeupQuery = "", $wakeupZeile = ""
_SQLite_Query(-1, "SELECT ip FROM Rechner WHERE mac = '" & $rechnerelement & "'", $wakeupQuery)
While _SQLite_FetchData($wakeupQuery, $wakeupZeile) = $SqlITE_OK
For $wakeupelement In $wakeupZeile
$broad = StringSplit($wakeupelement, ".")
RunWait(@ComSpec & " /c " & '"' & @ScriptDir & "\wake.exe" & '"' & " " & $mac & " " & $broad[1] & "." & $broad[2] & "." & $broad[3] & ".255")
Next
WEnd
Next
WEnd
_dbclose()
MsgBox(64, "Wakeup", "Die Rechner der Gruppe " & $name & " wurden aufgeweckt.", 2)
EndIf
EndFunc ;==>_Rechnerwakeup
_dbopen()
$rkategorie = _Rechnertreeviewupdate()
_dbclose()
$altrechnername = "alt"
While 1
$RechnerTreeView_selected = GUICtrlRead($RechnerTreeView, 1)
$rechnerkategorie = False
For $poolelement In $rkategorie
If $poolelement = $RechnerTreeView_selected Then
$rechnerkategorie = True
ExitLoop
EndIf
Next
If $RechnerTreeView_selected = "0" Then
[/autoit] [autoit][/autoit] [autoit]ElseIf $altrechnername = $RechnerTreeView_selected Then
[/autoit] [autoit][/autoit] [autoit]ElseIf $rechnerkategorie = False Then
$typ = "rechner"
$altrechnername = $RechnerTreeView_selected
[/autoit] [autoit][/autoit] [autoit]$Programmitem = _Programmliste($altrechnername, $typ)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]GUICtrlSetData($Rechnername, $RechnerTreeView_selected)
GUICtrlSetState($Rechnername, $GUI_SHOW)
$rechnergruppe = _Gruppe($RechnerTreeView_selected)
_GUICtrlComboBox_SelectString($Gruppe, $rechnergruppe)
GUICtrlSetState($Gruppe, $GUI_SHOW)
GUICtrlSetState($Gruppeaendern, $GUI_SHOW)
GUICtrlSetState($programmtree, $GUI_SHOW)
GUICtrlSetState($nGruppe, $GUI_SHOW)
GUICtrlSetState($Speichern, $GUI_SHOW)
GUICtrlSetState($Rechnerherunterfahren, $GUI_SHOW)
GUICtrlSetState($Rechnerneustart, $GUI_SHOW)
GUICtrlSetState($Rechnerwakeup, $GUI_SHOW)
Else
$typ = "kategorie"
$altrechnername = $RechnerTreeView_selected
[/autoit] [autoit][/autoit] [autoit]$Programmitem = _Programmliste($altrechnername, $typ)
[/autoit] [autoit][/autoit] [autoit]GUICtrlSetData($Rechnername, $RechnerTreeView_selected)
GUICtrlSetState($Rechnername, $GUI_SHOW)
GUICtrlSetState($Gruppe, $GUI_HIDE)
GUICtrlSetState($Gruppeaendern, $GUI_HIDE)
GUICtrlSetState($programmtree, $GUI_SHOW)
GUICtrlSetState($nGruppe, $GUI_HIDE)
GUICtrlSetState($Speichern, $GUI_SHOW)
GUICtrlSetState($Rechnerherunterfahren, $GUI_SHOW)
GUICtrlSetState($Rechnerneustart, $GUI_SHOW)
GUICtrlSetState($Rechnerwakeup, $GUI_SHOW)
EndIf
$nMsg = GUIGetMsg()
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Switch $nMsg
Case $GUI_EVENT_CLOSE
DriveMapDel("X:")
Exit
Case $nGruppe
$neueGruppe = InputBox("neue Gruppe", "Name der neuen Gruppe eingeben")
If @error = 1 Then
MsgBox(0, "Fehler", "Ein Fehler ist aufgetreten.")
Else
_dbopen()
_SQLite_Exec(-1, "UPDATE rechner SET kategorie = '" & $neueGruppe & "' WHERE name ='" & $RechnerTreeView_selected & "'")
$rkategorie = _Rechnertreeviewupdate()
_dbclose()
GUICtrlSetState($Rechnername, $GUI_HIDE)
GUICtrlSetState($Gruppe, $GUI_HIDE)
GUICtrlSetState($Gruppeaendern, $GUI_HIDE)
GUICtrlSetState($programmtree, $GUI_HIDE)
GUICtrlSetState($nGruppe, $GUI_HIDE)
EndIf
Case $Gruppeaendern
_dbopen()
_SQLite_Exec(-1, "UPDATE rechner SET kategorie = '" & GUICtrlRead($Gruppe) & "' WHERE name ='" & $RechnerTreeView_selected & "'")
$rkategorie = _Rechnertreeviewupdate()
_dbclose()
GUICtrlSetState($Rechnername, $GUI_HIDE)
GUICtrlSetState($Gruppe, $GUI_HIDE)
GUICtrlSetState($Gruppeaendern, $GUI_HIDE)
GUICtrlSetState($programmtree, $GUI_HIDE)
GUICtrlSetState($nGruppe, $GUI_HIDE)
Case $Speichern
_dbopen()
If $typ = "rechner" Then
_SQLite_Exec(-1, "DELETE FROM Zuweisenrechner WHERE rechnername = '" & $RechnerTreeView_selected & "'")
Else
_SQLite_Exec(-1, "DELETE FROM Zuweisenkategorie WHERE kategorie = '" & $RechnerTreeView_selected & "'")
EndIf
_dbclose()
For $programmitemelement In $Programmitem
$pruef = _GUICtrlTreeView_GetChecked($programmtree, $programmitemelement)
If $pruef = True Then
$programmname = _GUICtrlTreeView_GetText($programmtree, $programmitemelement)
_Install($RechnerTreeView_selected, $programmname)
EndIf
Next
_Programmliste($RechnerTreeView_selected, $typ)
Case $Rechnerherunterfahren
_Rechnerherunterfahren($typ, $RechnerTreeView_selected)
Case $Rechnerneustart
_Rechnerneustart($typ, $RechnerTreeView_selected)
Case $Rechnerwakeup
_Rechnerwakeup($typ, $RechnerTreeView_selected)
EndSwitch
WEnd
Hier die Wake.exe um PCs aufzuwecken: http://masterbootrecord.de/english/wakeup.php
Wenn es Fragen/Unklarheiten/Wünsche gibt einfach hier posten.
Sollte ihr das produktiv im Einsatz haben wäre ich über kleine Rückmeldung erfreut da mich das interessieren würde.