Jump to content

Read remote registry value and write it in GUI


Recommended Posts

Hi at all,

little question.

I have a GUI with an input field. In this field I write the name of a system in the network.

The script then (by clicking on the button) reads a registry value from the remote system and writes it in a second input field.

Later I want to edit this value an then write back to the remote system.

The problem I have is that the script reads the remote registry value. The value appears in the second input field, but when I move with the mouse over the input field the value disappears.

How do I get this value permanently for editing in the field?

Thanks

Here the code:

#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)


; Seriennummer
GUICtrlCreateLabel ("Seriennummer", 10, $PosLabel+100)
GUICtrlCreateInput ("", 20, $PosLabel+115, 100, 20, 0x0008)



; 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 = $ButtonExit
          Exit
        
        Case $msg = $ButtonAuslesen
            WerteAuslesen() 
            
    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\"
        $SerienNummer = RegRead($path, "Seriennummer")
        GUICtrlCreateInput ($SerienNummer, 20, $PosLabel+115, 100, 20, 0x0008)
        
    Else
        MsgBox (16, $ScriptName, "System nicht erreichbar")
    EndIf

EndFunc
Link to comment
Share on other sites

#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)

$Input1_2 = GUICtrlCreateInput ("", 20, $PosLabel+115, 100, 20, 0x0008)

; Seriennummer
GUICtrlCreateLabel ("Seriennummer", 10, $PosLabel+100)
GUICtrlCreateInput ("", 20, $PosLabel+115, 100, 20, 0x0008)

; 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 = $ButtonExit
          Exit
        
        Case $msg = $ButtonAuslesen
            WerteAuslesen()    
            
    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\"
        $SerienNummer = RegRead($path, "Seriennummer")
        GUICtrlSetData($Input1_2, $SerienNummer)
    Else
        MsgBox (16, $ScriptName, "System nicht erreichbar")
    EndIf

EndFunc

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...