Zunächst einmal recht herzlichen Dank für eure Hilfe. Ich motze nicht, ich finde AutoIT eine absolut geniale Scriptsprache, sonst würde ich es nicht verwenden. Ich hinterfrage nur, weil ich neugierig bin, ich finde das nicht schlimm. Das ist meine Art zu lernen, ich vergleich dabei natürlich immer auch andere Sprachen mit denen ich bisher etwas zu tun hatte um Parallelen zu finden. Nun wird der einie oder ander jetzt verständlicher weise sagen, der Depp soll erst mal die Basics von AutoIt lernen, alla Hello Script und dann soll er weiter sehen. Ich bin aber eher der Typ der von einer konkreten Aufgabenstellung ausgehend, quasi Top Down sich eine Spreache erarbeitet, anders wird es für mich schnell langweilig. Mag sein dass die meisten das anders angehen, bei mir ist das halt so.
Das Script hatte ich nun schon einige Male gepostet, Es läuft von der GUI jetzt wie es soll. Hatte es nicht erneut gepostet, um mir nicht wieder anhören zu müssen, dass es jetzt sehr groß wäre, und letzlich keiner mehr durch blickt. Aber ich kann es gerne noch mal machen.
Mein Problem ist hier lediglich noch die Art der Variablendeklaration innerhalnb von Autoit. Der generelle Vorteil von Funktionen sollte ja die Wiederverwertbar keit sein, also aus meiner Sicht. So wäre es sehr schön, in einem Label halt durch Parameterangabe MSSQL, XXZ Dienst, dieses dort angeben zu können, das habe ich leider hier noch nicht hinbekommen. Im Wesentlichen brauch ich für mein Warungsscript auch nicht mehr, das die meisten Aufrufe PS/Batch Aufrufe sind. Diese werde ich zu gegebener Zeit gerne mit rübernehmen, aber im Moment ist das so ok. Also bleibt die Abfrage von Diensten, und die Funktionen hier doppelt reinzunehmen ist ja wohl nicht im Sinne des Erfinders.
Zum anderen wäre eine Aktualisierung der veränderlichen Labels wünschenswert, aber da habe ich, nach dem was ich in anderen Foren gelesen hatte, wenig Hoffnung.
HIer noch mal das DraftScript, die Interessierten
Mein spezieller Dank auch noch mal an Mombas, für die sachliche und themenbezogene Hilfestellung, so was ist tatsächlich selten in IT Foren!
#include-once
#include 'Service.au3'
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinApi.au3>
#include <String.au3>
#include "GUIBkImage.au3"
#include <GuiCtrlSetOnHover_UDF.au3>
FileInstall("C:\Users\Rickl\Pictures\DSC04006.jpg", "C:\Windows\Temp\hg.jpg", 1)
Global $BeepFile = 'C:\Windows\Temp\beep.wav'
Global $RBOX_EVENT_CLOSE = 1
Global $ROUNDES = 20, $LastHwnd = 0
Global $GUIBKCOLOR = 0xEEC591
Global $ARRAY_COLOR_TOP_MIN[3] = [36 ,65 ,142] , $ARRAY_COLOR_TOP_MAX[3] = [11 ,42 ,122]
Global $PCName = @ComputerName
Global $sFilePath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir")
Global $AugVers = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{92000000-2021-0000-0000-415547494153}", "DisplayVersion")
Global $WinBuild = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentBuild")
Global $WinDisplayVers = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DisplayVersion")
Global $WinName = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName")
Global $sTaskName = '_07_DataCollect'
Local $hGui = RBoxCreate("LAC WartungsTool Beta",840,600)
GUICtrlCreateLabel("CUSTOMIZING" & _StringRepeat(" ", 185) & "Local SQL-Server: " & _SQL(), 10, 35, 980, 20)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 9, 800) ; bold
GUICtrlCreateLabel($PCName, 610, 290, 980, 30)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 19, 800) ; bold
GUICtrlCreateLabel($WinBuild, 610, 330, 980, 20)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 9, 800) ; bold
GUICtrlCreateLabel($WinDisplayVers, 610, 350, 980, 20)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 9, 800) ; bold
GUICtrlCreateLabel($AugVers, 610, 370, 980, 20)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 9, 800) ; bold
GUICtrlCreateLabel($WinName, 610, 390, 980, 30)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 9, 800) ; bold
GUICtrlCreateLabel(" Web-Server : " & _Webserver(), 643, 50, 980, 20)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 9, 800) ; bold
Global $idButton_1 = GUICtrlCreateButton("Customize PC", 10, 55, 100, 20)
GUICtrlSetTip( -1, "Standard Image an Benutzer anpassen")
Global $idButton_2 = GUICtrlCreateButton("Image-Prepare", 130, 55, 100, 20)
GUICtrlSetTip( -1, "Vorinstallaierte Windows Version anpassen -> Image")
Global $idButton_3 = GUICtrlCreateButton("DL aktualisieren", 250, 55, 100, 20)
Global $idButton_4 = GUICtrlCreateButton("RegSettings", 370, 55, 100, 20)
Global $idButton_5 = GUICtrlCreateButton("TEST", 490, 55, 85, 20)
Global $idButton_11 = GUICtrlCreateButton("Standard Software", 10, 135, 100, 20)
Global $idButton_12 = GUICtrlCreateButton("Aufgaben", 130, 135, 100, 20)
Global $idButton_13 = GUICtrlCreateButton("Standard Proxies", 250, 135, 100, 20)
Global $idButton_14 = GUICtrlCreateButton("WinUpd Reset", 370, 135, 100, 20)
Global $idButton_15 = GUICtrlCreateButton("UPDATES", 490, 135, 100, 20)
Global $idButton_16 = GUICtrlCreateButton("Office registrieren", 610, 135, 100, 20)
Global $idButton_17 = GUICtrlCreateButton("Office Kill", 730, 135, 100, 20)
Global $idButton_18 = GUICtrlCreateButton("Domäne out/in", 10, 160, 100, 20)
Global $idButton_19 = GUICtrlCreateButton("APPS reparieren", 130, 160, 100, 20)
Global $idButton_20 = GUICtrlCreateButton("", 250, 160, 100, 20)
Global $idButton_21 = GUICtrlCreateButton("", 370, 160, 100, 20)
Global $idButton_22 = GUICtrlCreateButton("", 490, 160, 100, 20)
Global $idButton_23 = GUICtrlCreateButton("", 610, 160, 100, 20)
Global $idButton_24 = GUICtrlCreateButton("", 730, 160, 100, 20)
Global $idButton_32 = GUICtrlCreateButton("ggg", 10, 185, 100, 20)
Global $idButton_33 = GUICtrlCreateButton("", 130, 185, 100, 20)
Global $idButton_34 = GUICtrlCreateButton("", 250, 185, 100, 20)
Global $idButton_35 = GUICtrlCreateButton("", 370, 185, 100, 20)
Global $idButton_36 = GUICtrlCreateButton("gfgf", 490, 185, 100, 20)
Global $idButton_37 = GUICtrlCreateButton("VB ON temp", 610, 185, 100, 20)
Global $idButton_38 = GUICtrlCreateButton("VB OFF", 730, 185, 100, 20)
Global $idButton_39 = GUICtrlCreateButton("PC-CLEAN", 10, 240, 100, 20)
Global $idButton_40 = GUICtrlCreateButton("Win bereinigen", 130, 240, 100, 20)
Global $idButton_41 = GUICtrlCreateButton("Geräte Check", 250, 240, 100, 20)
Global $idButton_44 = GUICtrlCreateButton("", 610, 240, 100, 20)
Global $idButton_45 = GUICtrlCreateButton("", 730, 240, 100, 20)
Global $idButton_46 = GUICtrlCreateButton("Win RESET!", 10, 265, 100, 20)
Global $idButton_47 = GUICtrlCreateButton("Win Update Ass.", 130, 265, 100, 20)
Global $idButton_48 = GUICtrlCreateButton("", 250, 265, 100, 20)
Global $idButton_51 = GUICtrlCreateButton("MKLINK EPIC", 610, 265, 100, 20)
Global $idButton_52 = GUICtrlCreateButton("", 730, 265, 100, 20)
Global $idButton_53 = GUICtrlCreateButton("PC-List long", 490, 340, 100, 20)
Global $idButton_54 = GUICtrlCreateButton("PC-List short", 490, 365, 100, 20)
Global $idButton_55 = GUICtrlCreateButton("Inventar Liste", 490, 390, 100, 20)
Global $idButton_56 = GUICtrlCreateButton("Inventarisieren", 490, 315, 100, 20)
;GUICtrlCreatePic('C:\Windows\Temp\hg.jpg', 0, 25, 920, 660)
GUICtrlCreateLabel("Einzelmodule", 10, 115, 780, 20)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 9, 900) ; bold
GUICtrlCreateLabel("System-Wartung und Checks", 10, 220, 780, 20)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 9, 900) ; bold
GUICtrlCreateLabel("Datenbank", 10, 420, 780, 20)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 9, 900) ; bold
While True
CheckX($hGui,$RBOX_EVENT_CLOSE,"GuiCtrlSetColor("&$RBOX_EVENT_CLOSE&",0xA3A3A3)","GuiCtrlSetColor("&$RBOX_EVENT_CLOSE&",0x555555)")
$gMsg = GUIGetMsg()
Switch $gMsg
Case $GUI_EVENT_CLOSE, $RBOX_EVENT_CLOSE
GUIDelete($hGUI)
Exit
Case $idButton_1
$iPID = Run("C:\Users\Administrator\Downloads\PC-Einrichtung\PCSETTING_listv2.cmd", "", 10)
Case $idButton_2
$iPID = Run("C:\Users\Administrator\Downloads\CustomCOPY.bat", "", 10)
Case $idButton_3
MsgBox(0, "", 3)
Case $idButton_4
$filename = "C:\Program Files\Notepad++\notepad++.exe"
if FileExists($filename) Then
$prog = ShellExecute("C:\Program Files\Notepad++\notepad++.exe","C:\Windows\start\RegWerte_setzen.reg","","open",@SW_SHOW)
Else
;$prog = ShellExecute("C:\Windows\start\RegWerte_setzen.reg","","open",@SW_SHOW)
$prog = ShellExecute('notepad.exe', 'C:\Windows\start\RegWerte_setzen.reg')
EndIf
Case $idButton_5
$iPID = SoundPlay($BeepFile)
Case $idButton_11
RunWait(@ComSpec & " /c " & "C:\Users\Administrator\Downloads\PC-Einrichtung\AddedApps.cmd")
; $iPID = Run("C:\Users\Administrator\Downloads\PC-Einrichtung\AddedApps.cmd", "", 10)
SoundPlay($BeepFile)
Case $idButton_12
$iPID = RunWait(Run(@ComSpec & " /c " & "C:\Users\Administrator\Downloads\CreateTasks.cmd"))
;RunWait(@ComSpec & " /c " & "C:\Users\Administrator\Downloads\CreateTasks.cmd")
; $iPID = Run("C:\Users\Administrator\Downloads\PC-Einrichtung\AddedApps.cmd", "", 10)
SoundPlay($BeepFile)
Case $idButton_13
$iPID = RunWait(Run(@ComSpec & " /c " & "C:\Users\Administrator\Downloads\ETC\ProxyStandard.cmd"))
; RunWait(@ComSpec & " /c " & "C:\Users\Administrator\Downloads\ETC\ProxyStandard.cmd")
SoundPlay($BeepFile)
Case $idButton_14
RunWait(@ComSpec & " /c " & "C:\Users\Administrator\Downloads\TestTOOLS\WuReset.bat")
; $iPID = Run("C:\Users\Administrator\Downloads\PC-Einrichtung\AddedApps.cmd", "", 10)
SoundPlay($BeepFile)
Case $idButton_15
RunWait(@ComSpec & " /c " & "C:\Users\Administrator\Downloads\PC-Einrichtung\WinUpd.cmd")
; $iPID = Run("C:\Users\Administrator\Downloads\PC-Einrichtung\AddedApps.cmd", "", 10)
SoundPlay($BeepFile)
Case $idButton_16
RunWait(@ComSpec & " /c " & "C:\Users\Administrator\Downloads\ETC\OfficeRegister.cmd ")
; $iPID = Run("C:\Users\Administrator\Downloads\PC-Einrichtung\AddedApps.cmd", "", 10)
SoundPlay($BeepFile)
Case $idButton_17
RunWait(@ComSpec & " /c " & "C:\Users\Administrator\Downloads\PC-Einrichtung\Soft\officeKill.cmd", "", 10)
SoundPlay($BeepFile)
Case $idButton_19
RunWait(@ComSpec & " /c " & "C:\Users\Administrator\Downloads\PC-Einrichtung\TOOLS\TOOLS\AppsRepair.bat", "", 10)
SoundPlay($BeepFile)
Case $idButton_39
$iPID = Run(@ComSpec & " /c " & "C:\Users\Administrator\Downloads\Ordner_leeren.cmd")
;RunWait(@ComSpec & " /c " & "C:\Users\Administrator\Downloads\Ordner_leeren.cmd")
; SoundPlay($BeepFile)
Case $idButton_40
GUICtrlSetTip( -1, "Standard Image an Benutzer anpassen")
RunWait(@ComSpec & " /c " & "C:\Users\Administrator\Downloads\Datentraegerbereinigung\Dtclean.bat")
$iPID = SoundPlay($BeepFile)
Case $idButton_41
RunWait(@ComSpec & " /c " & "C:\Users\Administrator\Downloads\PC-Einrichtung\TestGeraete.cmd")
_SQL()
;MsgBox(0,"", "Es existiert eine Variable mit dem Namen: " & $st ) ;<= hier soll der name der variable stehen, nicht der wert
$iPID = SoundPlay($BeepFile)
Case $idButton_47
;ShellExecute("C:\Users\Administrator\Downloads\Windows10Upgrade9252.exe")
RunWait("C:\Users\Administrator\Downloads\Windows10Upgrade9252.exe")
$iPID = SoundPlay($BeepFile)
FileDelete ( "C:\Users\Riegert\Desktop\Windows 10-Update-Assistent.lnk" )
Case $idButton_53
GUICtrlSetTip( -1, "Standard Image an Benutzer anpassen")
RunWait(@ComSpec & " /c " & "V:\Austausch-Daten\Riegert\inv2\CSV-Merge10.bat")
$iPID = SoundPlay($BeepFile)
Case $idButton_54
GUICtrlSetTip( -1, "Standard Image an Benutzer anpassen")
RunWait(@ComSpec & " /c " & "V:\Austausch-Daten\Riegert\inv2\CSV-Merge_Short.bat")
$iPID = SoundPlay($BeepFile)
Case $idButton_55
GUICtrlSetTip( -1, "Inventar-Liste")
ShellExecute("\\ds1\Freigaben\Referat_5_Informationstechnologie\51_Hardware_und_Software\511_Inventare\5112_Invertarliste_Hardware\Hardware\Inventarliste Hardware.xls")
$iPID = SoundPlay($BeepFile)
Case $idButton_56
GUICtrlSetTip( -1, "Inventarisierungs-Script ausführen")
Local $sTaskName = '_07_DataCollect'
;RunWait("schtasks /Run /TN ' & "$sTaskName"')
; RunWait('schtasks.exe /Run /TN ' & $sTaskName, '', @SW_HIDE)
$iPID = SoundPlay($BeepFile)
EndSwitch
WEnd
Func RBoxCreate($Title,$width, $height ,$left=-1 ,$top=-1 ,$show=1)
Local $GUI = GUICreate($Title,$width,$height,$left,$top,$WS_POPUP)
GUISetBkColor($GUIBKCOLOR,$GUI)
;_GuiRoundCorners($GUI,0,0,$ROUNDES,$ROUNDES)
$RBOX_EVENT_CLOSE = GUICtrlCreateLabel('X',$width-20,3,25,25)
GUICtrlSetCursor($RBOX_EVENT_CLOSE,0)
GUICtrlSetBkColor($RBOX_EVENT_CLOSE,-2)
GUICtrlSetFont($RBOX_EVENT_CLOSE,15,800)
GUICtrlSetColor($RBOX_EVENT_CLOSE,0x555555)
$Title &= " "
Local $hTitle = GUICtrlCreateLabel($Title,0,0,$width-20,26,$SS_CENTER,$GUI_WS_EX_PARENTDRAG)
GUICtrlSetFont($hTitle,17,400,0,"Consolas")
GUICtrlSetBkColor($hTitle,-2)
Local $Graphic = GUICtrlCreateGraphic (0,0, $width, 25)
GUICtrlSetState($Graphic,$Gui_DISABLE)
;GradientFill($Graphic, 0, 0, $width, 25, $ARRAY_COLOR_TOP_MIN, $ARRAY_COLOR_TOP_MAX)
If $show = 1 Then GUISetState(@SW_SHOW,$GUI)
Return $GUI
EndFunc
Func CheckX($hGui, $CtrlID, $sCMD, $eCMD)
Local $cGui = GUIGetCursorInfo($hGui)
If Not IsArray($cGui) Then Return 0
if $LastHwnd <> $cGui[4] And $cGui[4] = $CtrlID Then Return Execute($sCMD) + Assign("LastHwnd",$cGui[4])
if $LastHwnd <> $cGui[4] Then Return Execute($eCMD) + Assign("LastHwnd",$cGui[4])
EndFunc
Func _SQL()
Local $st = false
Local $FileText ;fehlt!
Local Const $SeviceName = "SQL Server (AUGIAS)" ;name of the service to test ; Local Const fehlte
RunWait(@ComSpec & " /c net start > c:\temp\services.txt", "", @SW_HIDE);send a list of the services that are running to a file
;hier würde eine Prüfung Sinn machen
$FileText = FileRead("c:\temp\services.txt", FileGetSize("c:\temp\services.txt"));read that file
If StringInStr($FileText, $SeviceName) Then;check for the service name
$st = "RUNNING" ;ich würde True wählen
Else
$st = "OFF" ; ich würde False wählen
EndIf
Return $st
EndFunc
Func _Webserver()
Local $ws ;fehlt! und ich würde es hier direkt als = False setzen!
Local $FileText ;fehlt!
Local Const $SeviceName = "Apache2.4"
RunWait(@ComSpec & " /c net start > c:\temp\services.txt", "", @SW_HIDE)
;hier würde eine Prüfung Sinn machen
$FileText = FileRead("c:\temp\services.txt", FileGetSize("c:\temp\services.txt"));read that file
If StringInStr($FileText, $SeviceName) Then;check for the service name
$st = "RUNNING" ;ich würde True wählen
Else
$st = "OFF" ; ich würde False wählen
EndIf
Return $st
EndFunc
;;;;;;;;; wie am besten per parameter servicename in ein Label einbinden ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func Request_Service($Servicename)
if _Service_Exists($Servicename)then
Return Status(_Service_QueryStatus($Servicename)[1])
else
Return 'Service does not exist'
endif
endfunc
Func Status($Status)
Switch $Status
Case 1
$Status = 'SERVICE_STOPPED'
Case 2
$Status = 'SERVICE_START_PENDING'
Case 3
$Status = 'SERVICE_STOP_PENDING'
Case 4
$Status = 'SERVICE_RUNNING'
Case 5
$Status = 'SERVICE_CONTINUE_PENDING'
Case 6
$Status = 'SERVICE_PAUSE_PENDING'
Case 7
$Status = 'SERVICE_PAUSED'
Case Else
$Status = 'SERVICE_UNKNOWN_STATE'
EndSwitch
Return($Status)
EndFunc
Alles anzeigen
Ich habe die Stelle markiert, wo meine letzte Frage fürs erste hinzielt. So jetzt könnt Ihr wieder motzen mit mir;)
@Mombas: Mein Dienst heisst so;)
GUICtrlCreateLabel("CUSTOMIZING" & _StringRepeat(" ", 185) & "Local SQL-Server: " & Request_Service(MSSQL), 10, 35, 980, 20)
MSSQL ist der Dienstname
lg und schönen Abend noch