blumi Posted April 28, 2009 Share Posted April 28, 2009 Hi, I have a little problem with my script. Just want to read some registry values on a remote system in the network. The GUI has an input for the name of the remote system I want to read the registry values and two buttons for start reading and exit. If there is no name in the input field when I click on "Aktualisieren" (start reading) there should be a msgbox which tells to write a system name in the input field. IT works, but not correct. The msgbox appears, but after that the script will exit and the GUI will close. I want that the msgbox appears but after that there should be a second chance to type in the innput field the machine name and not exit the script. Don't know how to realize that. Thanks a lot. expandcollapse popup#RequireAdmin #include <GuiConstants.au3> #include <Process.au3> $ScriptName = "Check Registrierungsinfos" ; GUI - Breite und Höhe des Fensters GuiCreate($ScriptName, 300, 300) GuiSetIcon(@WindowsDir & "\Temp\EMI.ico", 0) ; Schrift GUISetFont (10, 400, 0, 0) GUICtrlCreateLabel ("Tool zum Überprüfen der Registrierungsinfos", 10, 20) $PosLabel = 60 GUISetFont (10, 400, 4, 0) ; Name des Systems GUICtrlCreateLabel ("Systemname:", 10, $PosLabel) $Input1_1 = GUICtrlCreateInput ("", 80, $PosLabel, 85, 20) ; Buttons $ButtonAuslesen = GuiCtrlCreateButton("&Auslesen", 40, 260, 100, 30) GUICtrlSetTip(-1, "Auslesen") $ButtonExit = GuiCtrlCreateButton("&Ende", 160, 260, 100, 30) GUICtrlSetTip(-1, "Programm beenden") ; Show the GUI GuiSetState () While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $ButtonExit Exit Case $msg = $ButtonAuslesen WerteAuslesen() ;Case $msg = $ButtonUeberpruefen ;WerteUeberpruefen() EndSelect WEnd GUIDelete() ; Funktionen Func WerteAuslesen() If GUICtrlRead($Input1_1) <> "" Then $CheckInput1_1 = TRUE Else $CheckInput1_1 = FALSE EndIf If ($CheckInput1_1 == TRUE) Then $ComputerName = GUICtrlRead($Input1_1) Else MsgBox (48, $ScriptName, "Bitte einen Systemnamen eingeben") EndIf ; System anpingen $status = Ping($ComputerName) If $status Then $path = "\\" & $ComputerName & "\HKLM\System\EMI\" $benutzer = RegRead($path, "Benutzer") $SerienNummer = RegRead($path, "Seriennummer") $InventaNummer = RegRead($path, "Inventarnummer") $VorgangsNummer = RegRead($path, "Vorgangsnummer") $message = "Benutzer: " & $benutzer & @LF $message = $message & "Seriennummer: " & $SerienNummer & @LF $message = $message & "Inventarnummer: " & $InventaNummer & @LF $message = $message & "Vorgangsnummer: " & $VorgangsNummer & @LF MsgBox (64, $ScriptName, $message) Else MsgBox (16, $ScriptName, "System nicht erreichbar") EndIf EndFunc Link to comment Share on other sites More sharing options...
picea892 Posted April 28, 2009 Share Posted April 28, 2009 Have this case point to a function instead of exit. In the function, have the messagebox remade. Case $msg = $GUI_EVENT_CLOSE Or $msg = $ButtonExit Exit Link to comment Share on other sites More sharing options...
blumi Posted April 28, 2009 Author Share Posted April 28, 2009 Changed it to Case $msg = $ButtonExit Now it works fine. ;-) Link to comment Share on other sites More sharing options...
picea892 Posted April 28, 2009 Share Posted April 28, 2009 Oh...well that's good. That's different than what I thought you wanted...... What I was suggesting is below. expandcollapse popup#RequireAdmin #include <GuiConstants.au3> #include <Process.au3> Global $GUIname, $firstexit=0, $ButtonExit, $ButtonAuslesen firstchance() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $ButtonExit anotherchance() Case $msg = $ButtonAuslesen WerteAuslesen() ;Case $msg = $ButtonUeberpruefen ;WerteUeberpruefen() EndSelect WEnd GUIDelete() ; Funktionen Func WerteAuslesen() If GUICtrlRead($Input1_1) <> "" Then $CheckInput1_1 = TRUE Else $CheckInput1_1 = FALSE EndIf If ($CheckInput1_1 == TRUE) Then $ComputerName = GUICtrlRead($Input1_1) Else MsgBox (48, $ScriptName, "Bitte einen Systemnamen eingeben") EndIf ; System anpingen $status = Ping($ComputerName) If $status Then $path = "\\" & $ComputerName & "\HKLM\System\EMI\" $benutzer = RegRead($path, "Benutzer") $SerienNummer = RegRead($path, "Seriennummer") $InventaNummer = RegRead($path, "Inventarnummer") $VorgangsNummer = RegRead($path, "Vorgangsnummer") $message = "Benutzer: " & $benutzer & @LF $message = $message & "Seriennummer: " & $SerienNummer & @LF $message = $message & "Inventarnummer: " & $InventaNummer & @LF $message = $message & "Vorgangsnummer: " & $VorgangsNummer & @LF MsgBox (64, $ScriptName, $message) Else MsgBox (16, $ScriptName, "System nicht erreichbar") EndIf EndFunc Func firstchance() $ScriptName = "Check Registrierungsinfos" ; GUI - Breite und Höhe des Fensters $GUIname=GuiCreate($ScriptName, 300, 300) GuiSetIcon(@WindowsDir & "\Temp\EMI.ico", 0) ; Schrift GUISetFont (10, 400, 0, 0) GUICtrlCreateLabel ("Tool zum Überprüfen der Registrierungsinfos", 10, 20) $PosLabel = 60 GUISetFont (10, 400, 4, 0) ; Name des Systems GUICtrlCreateLabel ("Systemname:", 10, $PosLabel) $Input1_1 = GUICtrlCreateInput ("", 80, $PosLabel, 85, 20) ; Buttons $ButtonAuslesen = GuiCtrlCreateButton("&Auslesen", 40, 260, 100, 30) GUICtrlSetTip(-1, "Auslesen") $ButtonExit = GuiCtrlCreateButton("&Ende", 160, 260, 100, 30) GUICtrlSetTip(-1, "Programm beenden") ; Show the GUI GuiSetState () EndFunc Func anotherchance() GUIDelete($GUIname) sleep(2000) if $firstexit=0 then firstchance() $firstexit=1 Else Exit EndIf EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now