Hi, ich hab ein dringendes Problem: Ich muss bis heut Mittag ein Programm fertighaben, dass mir eine Ausgabe einer rel. schmalen, dafür ziemlich langen Liste ausspuckt.Siehe Zeile 96/97 => Ausgabe der IP-Adresse, wird bei entsprechend vielen Netzwerkkarten ziemlich lange Ich habe entweder die Möglichkeit eine msgbox dafür zu verwenden oder eben in meine GUI-Liste zu verwenden. Nur ist aber bei er msgbox das Problem, dass bei zu kleinen Auflösungen nicht das ganze Fenster auf den Bildschirm passt und dann einfach abgeschnitten wird. Ist es nicht möglich dis abzufangen und bei z.B. einer maximalen Pixelanzahl eine BILdlaufleiste einzublenden?
Alternativ das ganze innerhalb meine Gui-Liste, auch mit Bildlaufleiste
=> Dort ist aber zusätzlich das Problem, dass die Daten nicht richtig den Zeilensprung machen, sprich "Alles wird in eine Zeile ausgegeben" (bei er msgbox geht das aber !)
Siehe Spoiler. Wär schön, wenns ne Lösung für mich gibt. THX
Spoiler anzeigen
#include <GUIConstants.au3>
#include <ServiceControl.au3>
#include <Constants.au3>
#Include <GuiList.au3>
;checks if another instance of this script runs simultaneously
$g_szVersion = "Servicescript Ver. 1.8"
If WinExists($g_szVersion) Then Exit ; It's already running
AutoItWinSetTitle($g_szVersion)
; create global variables
Global $button_exit_child, $button_ok_child,$text, $username, $ipconfig = "ipconfig", $cmd = "cmd /T:1F /K", $gpupdate = "gpupdate /force", $nslookup = "nslookup", $tracert = "tracert", $remoteaccess = "rcimlby.exe -LaunchRA"
; create the main gui-surface
$main = GUICreate("Service-Script V1.8", 650, 490)
GUISetState(@SW_SHOW)
$string = "Bitte wählen Sie eines der folgenden Programme aus, in dem Sie den entsprechenden Button auswählen und mit OK bestätigen. Zum Beenden des Programms, bitte Exit wählen. Zum Löschen der Anzeige, Clear wählen."
GUICtrlCreateLabel(_StringInsertLF($String,60),10,15)
$button_ok = GUICtrlCreateButton("OK", 10, 120, 200, 35, -1, -1)
$button_clear = GUICtrlCreateButton("Clear", 10, 170, 90, 35, -1, -1)
$button_exit = GUICtrlCreateButton("Exit", 125, 170, 90, 35, -1, -1)
$out = GUICtrlCreateList("", 10, 230, 320, 250, ($ws_vscroll + $WS_BORDER + $LBS_NOTIFY + $LBS_NOINTEGRALHEIGHT))
GUISetIcon("trash.ico", 0)
GUISetState()
GUICtrlCreateLabel(@ComputerName, 360, 30, 270, 20)
GUICtrlCreateGroup("1. Ihr PC-Name ist: ", 340, 10, 300, 50)
GUICtrlCreateGroup("5. Admin Tools", 340, 390, 300, 90)
GUICtrlCreateGroup("4. Windows Tools", 340, 290, 300, 90)
GUICtrlCreateGroup("3. Netzwerktools", 340, 170, 300, 110)
GUICtrlCreateGroup("2. Ausführen des Ping auf Rechner:", 340, 70, 300, 90)
;create radio-buttons for the different functions
$radio_21 = GUICtrlCreateRadio("srv01mail1", 350, 90, 140, 20)
$radio_22 = GUICtrlCreateRadio(@ComputerName, 350, 110, 140, 20)
$radio_23 = GUICtrlCreateRadio("srv32sis", 350, 130, 140, 20)
$radio_20 = GUICtrlCreateRadio("eigene Eingabe", 490, 90, 140, 20)
$radio_30 = GUICtrlCreateRadio("IP-Adressen des Rechners anzeigen", 350, 190, 280, 20)
$radio_31 = GUICtrlCreateRadio("Policy-Refresh", 350, 210, 280, 20)
$radio_32 = GUICtrlCreateRadio("NSLOOKUP auf Ditzingen / Böblingen", 350, 230, 280, 20)
$radio_33 = GUICtrlCreateRadio("Trace Route auf Server x", 350, 250, 280, 20)
$radio_40 = GUICtrlCreateRadio("Computermanagement öffnen", 350, 310, 280, 20)
$radio_41 = GUICtrlCreateRadio("Eventviewer starten", 350, 330, 280, 20)
$radio_42 = GUICtrlCreateRadio("Windows Remote Assistance starten", 350, 350, 280, 20)
$radio_50 = GUICtrlCreateLabel("Firewall",370,410,50,20)
$button_off = GUICtrlCreateButton("AUS", 480, 410, 50, 15, -1, -1)
$button_on = GUICtrlCreateButton("AN", 420, 410, 50, 15, -1, -1)
$radio_51 = GUICtrlCreateRadio("Lokalen Benutzer entsperren", 350, 430, 280, 20)
$radio_52 = GUICtrlCreateRadio("DOS-Box mit Adminrechten starten", 350, 450, 280, 20)
; create the child_gui for the "unlock local user" function
$child = GUICreate("Bitte Benutzernamen eingeben", 250, 100)
GUISetState(@SW_HIDE, $child)
; while-loop to get the state of pressed buttons
While 1
$msg = GUIGetMsg(1)
Select
Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $main ; closes the main windows by pressing "X" at the right upper corner
Exit
Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $child ; closes the child-gui by pressing "X" at the right upper corner, main-gui remains open
GUISetState(@SW_HIDE, $child)
Case $msg[0] = $button_clear And $msg[1] = $main ; deletes all enties in the listbox and unchecks the active radio_button
ClearFields($out,$radio_20,$radio_21,$radio_22,$radio_23,$radio_30,$radio_31,$radio_32,$radio_33,$radio_40,$radio_41,$radio_42,$radio_50,$radio_51,$radio_52)
Case $msg[0] = $button_exit ; closes complete programm by clicking the exit-button
Exit
Case $msg[0] = $button_exit_child ; closes the child-gui by clicking the child-exit-button
GUISetState(@SW_Hide, $child)
Case $msg[0] = $button_ok And (GUICtrlRead($radio_20) = $GUI_Checked) And $msg[1] = $main ; pings a user-defined computer
$p = InputBox("Ping auf beliebigen Server", "Bitte einen Servernamen eingeben: ", "", " M")
PingServ($p)
Case $msg[0] = $button_ok And (GUICtrlRead($radio_21) = $GUI_Checked) And $msg[1] = $main ; pings srv01mail1
PingServ("srv01mail1")
Case $msg[0] = $button_ok And (GUICtrlRead($radio_22) = $GUI_Checked) And $msg[1] = $main ; pings localhost
PingServ(@ComputerName)
Case $msg[0] = $button_ok And (GUICtrlRead($radio_23) = $GUI_Checked) And $msg[1] = $main ; pings srv32sis
PingServ("srv32sis")
Case $msg[0] = $button_ok And (GUICtrlRead($radio_30) = $GUI_Checked) And $msg[1] = $main ; shows the IP adress and status of all connected network devices
ClearFields($out,$radio_20,$radio_21,$radio_22,$radio_23,$radio_30,$radio_31,$radio_32,$radio_33,$radio_40,$radio_41,$radio_42,$radio_50,$radio_51,$radio_52)
$stream = Run(@ComSpec & ' /c ' & $ipconfig, '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
$text = ""
While 1
$textline = StdoutRead($stream)
$text = $text & @CRLF & $textline
If @error Then ExitLoop
WEnd
MsgBox(0, "Die Route zum Server ist:", $text)
GUICtrlSetData($out, _StringInsertLF($text,60))
Case $msg[0] = $button_ok And (GUICtrlRead($radio_52) = $GUI_Checked) And $msg[1] = $main ; opens dos-shell with local administrator rights
ClearFields($out,$radio_20,$radio_21,$radio_22,$radio_23,$radio_30,$radio_31,$radio_32,$radio_33,$radio_40,$radio_41,$radio_42,$radio_50,$radio_51,$radio_52)
Run(@ComSpec & " /c " & $cmd, @SystemDir, @SW_SHOW)
Case $msg[0] = $button_ok And (GUICtrlRead($radio_31) = $GUI_Checked) And $msg[1] = $main ; updates Windows Policy
ClearFields($out,$radio_20,$radio_21,$radio_22,$radio_23,$radio_30,$radio_31,$radio_32,$radio_33,$radio_40,$radio_41,$radio_42,$radio_50,$radio_51,$radio_52)
GUICtrlSetData($out, "Refresh der Policy startet")
Opt("WinWaitDelay", 100)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 0)
Run('C:\WINDOWS\system32\cmd.exe', "", @SW_HIDE)
WinWait("C:\WINDOWS\system32\cmd.exe", "")
If Not WinActive("C:\WINDOWS\system32\cmd.exe", "") Then WinActivate("C:\WINDOWS\system32\cmd.exe", "")
WinWaitActive("C:\WINDOWS\system32\cmd.exe", "")
Send("gpupdate /force")
Send("{ENTER}")
GUICtrlSetData($out, "-------------------------------------------------------------" & "|" & "Bitte warten, die Policy wird erneuert.")
Sleep(20000)
Send("n" & "{ENTER}" & "exit" & "{ENTER}")
GUICtrlSetData($out, "-------------------------------------------------------------" & "|" & "Die Policy wurde erfolgreich erneuert")
Case $msg[0] = $button_ok And (GUICtrlRead($radio_32) = $GUI_Checked) And $msg[1] = $main ; runs nslookup of a user defined computer
ClearFields($out,$radio_20,$radio_21,$radio_22,$radio_23,$radio_30,$radio_31,$radio_32,$radio_33,$radio_40,$radio_41,$radio_42,$radio_50,$radio_51,$radio_52)
$server = InputBox("Nslookup auf Server X", "Bitte den Servernamen eingeben: ", "", " M")
IF @error=1 Then
Sleep(1)
Else
$stream = Run(@ComSpec & ' /c ' & $nslookup & " " & $server, '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
$text = ""
While 1
$textline = StdoutRead($stream)
$text = $text & @CRLF & $textline
If @error Then ExitLoop
WEnd
MsgBox(0, "Ergebnis:", _StringInsertLF($text,50))
EndIf
Case $msg[0] = $button_ok And (GUICtrlRead($radio_33) = $GUI_Checked) And $msg[1] = $main ; opens traceroute of a user defined computer
ClearFields($out,$radio_20,$radio_21,$radio_22,$radio_23,$radio_30,$radio_31,$radio_32,$radio_33,$radio_40,$radio_41,$radio_42,$radio_50,$radio_51,$radio_52)
$server = InputBox("Traceroute auf Server X", "Bitte den Servernamen eingeben: ", "", " M")
IF @error=1 Then
Sleep(1)
Else
Tracert($server)
EndIf
Case $msg[0] = $button_ok And (GUICtrlRead($radio_40) = $GUI_Checked) And $msg[1] = $main; opens computermanagement
ClearFields($out,$radio_20,$radio_21,$radio_22,$radio_23,$radio_30,$radio_31,$radio_32,$radio_33,$radio_40,$radio_41,$radio_42,$radio_50,$radio_51,$radio_52)
Run(@ComSpec & " /c " & 'compmgmt.msc', "", @SW_HIDE)
Case $msg[0] = $button_ok And (GUICtrlRead($radio_41) = $GUI_Checked) And $msg[1] = $main; opens windows eventviewer
ClearFields($out,$radio_20,$radio_21,$radio_22,$radio_23,$radio_30,$radio_31,$radio_32,$radio_33,$radio_40,$radio_41,$radio_42,$radio_50,$radio_51,$radio_52)
Run(@ComSpec & " /c " & 'eventvwr.msc', "", @SW_HIDE)
Case $msg[0] = $button_ok And (GUICtrlRead($radio_42) = $GUI_Checked) And $msg[1] = $main; starts Windows Remote Assistance
ClearFields($out,$radio_20,$radio_21,$radio_22,$radio_23,$radio_30,$radio_31,$radio_32,$radio_33,$radio_40,$radio_41,$radio_42,$radio_50,$radio_51,$radio_52)
Run($remoteaccess)
Case $msg[0] = $button_on And $msg[1] = $main; starts Windows Firewall service "sharedaccess"
ClearFields($out,$radio_20,$radio_21,$radio_22,$radio_23,$radio_30,$radio_31,$radio_32,$radio_33,$radio_40,$radio_41,$radio_42,$radio_50,$radio_51,$radio_52)
_startService ("", "sharedaccess")
$err = @error
Select
Case $err = 0
GUICtrlSetData($out, "Die Windows Firewall wurde aktiviert")
Case $err = 1056
GUICtrlSetData($out, "Der Windows-Firewalldienst ist bereits aktiv")
Case Else
GUICtrlSetData($out, "Es sind Fehler aufgetreten,|der Dienst konnte nicht erfolgreich gestartet werden |Evtl fehlen die Admin-Berechtigungen")
EndSelect
Case $msg[0] = $button_off And $msg[1] = $main; stopps Windows Firewall service "sharedaccess"
ClearFields($out,$radio_20,$radio_21,$radio_22,$radio_23,$radio_30,$radio_31,$radio_32,$radio_33,$radio_40,$radio_41,$radio_42,$radio_50,$radio_51,$radio_52)
_StopService ("", "sharedaccess")
$err = @error
Select
Case $err = 0
GUICtrlSetData($out, "Die Windows Firewall wurde erfolgreich beendet")
Case $err = 1062
GUICtrlSetData($out, "Der Windows-Firewalldienst war bereits beendet")
Case Else
GUICtrlSetData($out, "Es sind Fehler aufgetreten,|der Dienst konnte nicht erfolgreich beendet werden |Evtl fehlen die Admin-Berechtigungen")
EndSelect
Case $msg[0] = $button_ok And (GUICtrlRead($radio_51) = $GUI_Checked) And $msg[1] = $main; unlocks a local user, sets password to "initinit" and sets "user must change password at next logon"
ClearFields($out,$radio_20,$radio_21,$radio_22,$radio_23,$radio_30,$radio_31,$radio_32,$radio_33,$radio_40,$radio_41,$radio_42,$radio_50,$radio_51,$radio_52)
$input = InputBox("Unlock User","Bitte Benutzernamen eingeben:")
If $input = "Administrator" or $input = "Gast" or $input="guest" or $input = "" Then
$string="Administrator und Gast-Benutzer können nicht entsperrt werden. Bitte wählen Sie einen anderen Benutzer aus. Außerdem müssen Sie zwingend einen existenten Benutzer eingeben."
MsgBox(0,"",_StringInsertLF($String,50))
Else
$cusrmgr = "c:\windows\cusrmgr -u " & $input & " +s AccountLockout -s AccountDisabled +s MustChangePassword +p initinit"
Run($cusrmgr)
Sleep(2000)
MsgBox(0,"","Der Benutzer " & $input & " wurde erfolgreich entsperrt.")
EndIf
EndSelect
WEnd
Func ClearFields($out,$radio_20,$radio_21,$radio_22,$radio_23,$radio_30,$radio_31,$radio_32,$radio_33,$radio_40,$radio_41,$radio_42,$radio_50,$radio_51,$radio_52) ; resets all radio buttons and the listbox
_GUICtrlListClear($out)
GUICtrlSetState($radio_20, $GUI_unchecked)
GUICtrlSetState($radio_21, $GUI_unchecked)
GUICtrlSetState($radio_22, $GUI_unchecked)
GUICtrlSetState($radio_23, $GUI_unchecked)
GUICtrlSetState($radio_30, $GUI_unchecked)
GUICtrlSetState($radio_31, $GUI_unchecked)
GUICtrlSetState($radio_32, $GUI_unchecked)
GUICtrlSetState($radio_33, $GUI_unchecked)
GUICtrlSetState($radio_40, $GUI_unchecked)
GUICtrlSetState($radio_41, $GUI_unchecked)
GUICtrlSetState($radio_42, $GUI_unchecked)
GUICtrlSetState($radio_50, $GUI_unchecked)
GUICtrlSetState($radio_51, $GUI_unchecked)
GUICtrlSetState($radio_52, $GUI_unchecked)
EndFunc ;==>ClearFields
Func PingServ($ping) ; function for pinging computers on the network
ClearFields($out,$radio_20,$radio_21,$radio_22,$radio_23,$radio_30,$radio_31,$radio_32,$radio_33,$radio_40,$radio_41,$radio_42,$radio_50,$radio_51,$radio_52)
GUICtrlSetData($out, "Please wait...")
Dim $Prt, $ProgName, $Optionen, $MaxB = 0, $i, $PrtArray
$i = Run(@ComSpec & " /c ping " & $ping, @SystemDir, @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD)
ProcessWaitClose($i)
$h = StdoutRead($i)
If @error = 0 Then $Prt = $h
$h = StderrRead($i)
If @error = 0 Then $Prt = $h
$Prt = StringReplace($Prt, Chr(154), "Ü")
$Prt = StringReplace($Prt, Chr(129), "ü")
$Prt = StringReplace($Prt, Chr(142), "Ä")
$Prt = StringReplace($Prt, Chr(132), "ä")
$Prt = StringReplace($Prt, Chr(153), "Ö")
$Prt = StringReplace($Prt, Chr(148), "ö")
$Prt = StringReplace($Prt, Chr(10), "")
$Zeilen = StringSplit($Prt, @CR)
ClearFields($out,$radio_20,$radio_21,$radio_22,$radio_23,$radio_30,$radio_31,$radio_32,$radio_33,$radio_40,$radio_41,$radio_42,$radio_50,$radio_51,$radio_52)
For $v = 1 To $Zeilen[0] Step 1
If StringLen(StringStripWS($Zeilen[$v], 8)) > 0 Then
GUICtrlSetData($out, ($Zeilen[$v]) & "|")
EndIf
Next
EndFunc
Func Tracert($server) ; function for pinging computers on the network
ClearFields($out,$radio_20,$radio_21,$radio_22,$radio_23,$radio_30,$radio_31,$radio_32,$radio_33,$radio_40,$radio_41,$radio_42,$radio_50,$radio_51,$radio_52)
GUICtrlSetData($out, "Please wait...")
Dim $Prt, $ProgName, $Optionen, $MaxB = 0, $i, $PrtArray
$i = Run(@ComSpec & $tracert & $server, @SystemDir, @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD)
ProcessWaitClose($i)
$h = StdoutRead($i)
If @error = 0 Then $Prt = $h
$h = StderrRead($i)
If @error = 0 Then $Prt = $h
$Prt = StringReplace($Prt, Chr(154), "Ü")
$Prt = StringReplace($Prt, Chr(129), "ü")
$Prt = StringReplace($Prt, Chr(142), "Ä")
$Prt = StringReplace($Prt, Chr(132), "ä")
$Prt = StringReplace($Prt, Chr(153), "Ö")
$Prt = StringReplace($Prt, Chr(148), "ö")
$Prt = StringReplace($Prt, Chr(10), "")
$Zeilen = StringSplit($Prt, @CR)
ClearFields($out,$radio_20,$radio_21,$radio_22,$radio_23,$radio_30,$radio_31,$radio_32,$radio_33,$radio_40,$radio_41,$radio_42,$radio_50,$radio_51,$radio_52)
For $v = 1 To $Zeilen[0] Step 1
If StringLen(StringStripWS($Zeilen[$v], 8)) > 0 Then
GUICtrlSetData($out, ($Zeilen[$v]) & "|")
EndIf
Next
EndFunc
Func _StringInsertLF($strString,$nCount,$cBreaking = 0)
Local $strRetString = "", $nPos
Do
If Stringlen($strString) > $nCount Then
$nPos = StringInStr(StringLeft($strString,$nCount + 1)," ",0,-1)
If ($nPos and $cBreaking = 0) Then
$strRetString &= StringLeft($strString,$nPos - 1) & @LF
$strString = StringMid($strString,$nPos + 1)
Else
$strRetString &= StringLeft($strString,$nCount) & @LF
$strString = StringMid($strString,$nCount + 1)
EndIf
EndIf
Until StringLen($strString) < $nCount
$strRetString &= $strString
Return $strRetString
EndFunc