Cirusnb

Set Checked / un-checked value according to Registry value

7 posts in this topic

#1 ·  Posted (edited)

Hi all, first post here ever, I'm working on a project, Helpdesk type tool.   I'm trying to set the State (Checked, Unchecked) of check boxes, and Or button, (a Toggle). this would be set by determining the Value of Certain Reg keys,    here is my phone below. $PC_select_data is the Computer Name so you could replace it with "@Computer".  

I looked and looked and couldn't find whats wrong. 

I'm new to Autoit somewhat. 

I may be complicating things by assigning Arrays for my controls, but I think this will work. 

the first part is fine, I get a Computer from a list (that I got from AD with Water's Awesome UDF)

please not I'm using onevent also, well. the UDF OnEventA that allows upto 4 ByVal or Ref's 

I get the Value $PC_selected_data

return the value to the Function

 I send a test Key with Regread, if I can't read it I launch sc.exe to run Remote Reg.

Then I read 5 values from the Remote Reg.   I assigned a Array of those Values and Also Assigned a Array of my CheckBoxes also.

Now my logic, if the Value of the REG key is "" (blank)   then UnCheck all the check boxes, else, Check them. Now, to make this more efficient, I put the Controls in an Array, of the Same Lenth. now here is the think, I run my script, it runs fine, finds the value, and Un-checks all of the check boxes, now if I go change one of the REG values, it does not Check them. because of the Logic for the For Loop.   I would have figured that If the first value of the Array $Run_as_MSIscheck =  somevalue that it would see that as a "ELSE" and Check the box. Since the For loop contains the If - then- Else, but I Understand that it only runs the first Block, IF the condition is True.  So I guess Am I totally off track? 

 

Func Check_PC_status($PC_select_Data)
local $pingPC
local $regtemp = ""
local $x = ""
local $Run_as_MSIcheck,$Run_as_CMDcheck,$Run_as_BATCheck,$Run_as_REGcheck
local $RUNas_chks[4] = [$MSI_runAs_chk,$CMD_runAs_chk,$BAT_runAs_chk,$REG_runAs_chk]
local $runAS_function_check[4] = [$Run_as_MSIcheck,$Run_as_CMDcheck,$Run_as_BATCheck,$Run_as_REGcheck]

;~ @error:  
;~ 1 = Host is offline
;~ 2 = Host is unreachable
;~ 3 = Bad destination
;~ 4 = Other errors

;Sends Ping to pc to see if its live or not.
    
$pingPC = ping($PC_select_Data,2000)
;if Ping has returned a good value, NOT 0.  check current status of the following lines in registry. checkes for RunAS for CMD/MSI/BAT and Remote REG keys. checks for SMS prompt control.  
if $pingPC Then  
                
;tries to read a key from the registry, and returns its value, if its blank,
$regtemp = RegRead("\\" & $PC_select_Data & "\HKLM\SOFTWARE\Microsoft\SMS\Client\Client Components\Remote Control", "Permission Required")
ConsoleWrite("Sending test Key, is set to: " & $regtemp & @CRLF) 

;~error: 3 = Bad destination
if @error = 3  or $regtemp = "" Then
    ConsoleWrite("Unable to determine status of remote registry!!!" & @CRLF & "Trying to start Remote Registry.... via Service Control Manager" & @CRLF )

RunWait(@SystemDir & '\sc.exe \\' & $PC_select_Data & ' start RemoteRegistry',"","")
    if Not @error then 
    ConsoleWrite("Remote Registry loaded" & @CRLF & @CRLF)
    EndIf
EndIf
        
            TCPStartup()
                $IPadd = TCPNameToIP ($PC_select_Data)
                ConsoleWrite($IPadd & @CRLF)
            TCPShutdown()
                
            ConsoleWrite("ping Success: " & $pingPC & "ms" & @CRLF)
            
            $Sccm_PROMPTcheck = RegRead("\\" & $PC_select_Data & "\HKLM\SOFTWARE\Microsoft\SMS\Client\Client Components\Remote Control", "Permission Required")
            $Run_as_MSIcheck =  RegRead("\\" & $PC_select_Data & "\HKEY_CLASSES_ROOT\Msi.Package\shell\runas\command", "")  ; MSI access Check
            $Run_as_CMDcheck =  RegRead("\\" & $PC_select_Data & "\HKEY_CLASSES_ROOT\cmdfile\shell\runas\command", "")  ; CMS access Check
            $Run_as_BATCheck =  RegRead("\\" & $PC_select_Data & "\HKEY_CLASSES_ROOT\batfile\shell\runas\command", "")  ; BAT access Check
            $Run_as_REGcheck =  RegRead("\\" & $PC_select_Data & "\HKEY_CLASSES_ROOT\regfile\shell\runas\command", "")  ; REG access Check
            
            ConsoleWrite("SMS Client status: " & $Sccm_Promptcheck & @CRLF & "MSI RunAS Status: " & $Run_as_MSIcheck & @CRLF & "CMD RunAs Status: " & $Run_as_CMDcheck & @CRLF & "BAT RunAs Status: " & $Run_as_BATCheck & @CRLF & "REG RunAs Status: " & $Run_as_REGcheck & @CRLF & @CRLF)
    
            
    
        for $x = 0 to UBound($runAS_function_check) -1
            ConsoleWrite("Count: " & $x & @CRLF)
            
            if $runAS_function_check[$x] = "" Then
                                
                $test1 = guictrlread($RUNas_chks[$x])
                ConsoleWrite("B4 " & $test1 & @CRLF)
                
                GUICtrlSetState($RUNas_chks[$x],$GUI_UNCHECKED)
            
                $test2 =  guictrlread($RUNas_chks[$x])
                ConsoleWrite("After " & $test2 & @CRLF)
            
            Else
                
                    GUICtrlSetState($RUNas_chks[$x],$GUI_CHECKED)
                        
        EndIf
            
            
        Next
    
    Else
        
    ConsoleWrite($PC_select_Data & " is Not reachable" & @CRLF & @CRLF)
    
    
    EndIf
    
    
Endfunc

any help is appreciated. 

Edited by Cirusnb

Share this post


Link to post
Share on other sites



It's a little confusing.  I don't see any checkboxes in your snippet above.  I see your arrays which you are filling with zeros.  

I think know where you're going with this, but the execution isn't quite right.  

When you are doing your RegReads to update the *check variables, are you expecting that the arrays are being updated?  It doesn't work that way.  

I'd recommend something like this (apologies if this isn't the direction you wanted to take and this just added confusion)
 

;...
;Create Enumerated Variables - Human Friendly Array Indexes ;)
Local Enum $Run_as_MSIcheck, $Run_as_CMDcheck, $Run_as_BATCheck, $Run_as_REGcheck
;Create Array
Local $RUNas_chks[4]
;...
;Read Registry Values into Array
$RUNas_chks[$Run_as_MSIcheck] =  RegRead("\\" & $PC_select_Data & "\HKEY_CLASSES_ROOT\Msi.Package\shell\runas\command", "")  ; MSI access Check
$RUNas_chks[$Run_as_CMDcheck] =  RegRead("\\" & $PC_select_Data & "\HKEY_CLASSES_ROOT\cmdfile\shell\runas\command", "")  ; CMS access Check
$RUNas_chks[$Run_as_BATCheck] =  RegRead("\\" & $PC_select_Data & "\HKEY_CLASSES_ROOT\batfile\shell\runas\command", "")  ; BAT access Check
$RUNas_chks[$Run_as_REGcheck] =  RegRead("\\" & $PC_select_Data & "\HKEY_CLASSES_ROOT\regfile\shell\runas\command", "")  ; REG access Check
;...etc.

 

1 person likes this

Share this post


Link to post
Share on other sites

Like this?
 

Global $hForm = GUICreate("PC Status", 340, 90)
GUICtrlCreateLabel("PC: ", 24, 16, 32, 17)
Global $cSMS = GUICtrlCreateCheckbox("SMS", 16, 48, 46, 17)
Global $cMSI = GUICtrlCreateCheckbox("MSI", 64, 48, 46, 17)
Global $cCMD = GUICtrlCreateCheckbox("CMD", 112, 48, 46, 17)
Global $cBAT = GUICtrlCreateCheckbox("BAT", 160, 48, 46, 17)
Global $cREG = GUICtrlCreateCheckbox("REG", 208, 48, 46, 17)
Global $PC = GUICtrlCreateInput(@IPAddress1, 56, 16, 185, 21)
Global $CheckPC = GUICtrlCreateButton("Check", 256, 16, 73, 49)
Global $cStatus = GUICtrlCreateLabel("", 8, 72, 324, 17, BitOR(0x1, 0x0200))
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $CheckPC
            _CheckPC_Status(GUICtrlRead($PC))
    EndSwitch
    Sleep(10)
WEnd

Func _CheckPC_Status($sPC_Name)
    If StringStripWS($sPC_Name, 9) = "" Then Return SetError(1, 0, 0)
    Local $Sccm_PROMPTcheck, $sMSIcheck, $sCMDcheck, $sBATCheck, $sREGcheck, $sIPAddress, $regtemp, $iPID, $sOutput
    Local $pingPC = Ping($sPC_Name, 2000)
    If $pingPC Then
        $regtemp = RegRead("\\" & $sPC_Name & "\HKLM\SOFTWARE\Microsoft\SMS\Client\Client Components\Remote Control", "Permission Required")
        If @error = 3 Or $regtemp = "" Then
            ConsoleWrite("!Unable to determine status of remote registry!!!" & @CRLF & "-Trying to start Remote Registry.... via Service Control Manager" & @CRLF)
            $iPID = Run('"' & @SystemDir & '\sc.exe" ' & "\\" & $sPC_Name & ' start RemoteRegistry', "", @SW_HIDE, 8)
            ProcessWaitClose($iPID)
            $sOutput = StdoutRead($iPID)
            If StringInStr($sOutput, "FAILED") Then
                GUICtrlSetData($cStatus, "Can't load Remote Registry !")
                ConsoleWrite("! Can't load Remote Registry !" & @CRLF)
                Return SetError(2, 0, 0)
            Else
                GUICtrlSetData($cStatus, "Remote Registry loaded")
                ConsoleWrite("+Remote Registry loaded" & @CRLF)
            EndIf
        EndIf
        TCPStartup()
        $sIPAddress = TCPNameToIP($sPC_Name)
        ConsoleWrite("!IP: " & $sIPAddress & @CRLF)
        TCPShutdown()
        ConsoleWrite("-Ping Success: " & $pingPC & "ms" & @CRLF)
        $Sccm_PROMPTcheck = RegRead("\\" & $sPC_Name & "\HKLM\SOFTWARE\Microsoft\SMS\Client\Client Components\Remote Control", "Permission Required")
        $sMSIcheck = RegRead("\\" & $sPC_Name & "\HKEY_CLASSES_ROOT\Msi.Package\shell\runas\command", "")
        $sCMDcheck = RegRead("\\" & $sPC_Name & "\HKEY_CLASSES_ROOT\cmdfile\shell\runas\command", "")
        $sBATCheck = RegRead("\\" & $sPC_Name & "\HKEY_CLASSES_ROOT\batfile\shell\runas\command", "")
        $sREGcheck = RegRead("\\" & $sPC_Name & "\HKEY_CLASSES_ROOT\regfile\shell\runas\command", "")
        RegWrite("\\" & $sPC_Name & "\HKEY_CLASSES_ROOT\regfile\shell\runas\command", "", "REG_DWORD", 1)
        _Check($Sccm_PROMPTcheck, $cSMS)
        _Check($sMSIcheck, $cMSI)
        _Check($sCMDcheck, $cCMD)
        _Check($sBATCheck, $cBAT)
        _Check($sREGcheck, $cREG)
        ConsoleWrite("+SMS Client status: " & $Sccm_PROMPTcheck & @CRLF & "+MSI RunAS Status: " & $sMSIcheck & @CRLF & "+CMD RunAs Status: " & $sCMDcheck & @CRLF & "+BAT RunAs Status: " & $sBATCheck & @CRLF & "+REG RunAs Status: " & $sREGcheck & @CRLF & @CRLF)
        GUICtrlSetData($cStatus, "PC Status check done!")
    Else
        ConsoleWrite($sPC_Name & " is Not reachable" & @CRLF & @CRLF)
        SetError(1, 0, 0)
    EndIf
EndFunc   ;==>_CheckPC_Status

Func _Check($Data, $Control)
    If StringStripWS($Data, 8) <> "" Then
        GUICtrlSetState($Control, 1)
    Else
        GUICtrlSetState($Control, 4)
    EndIf
EndFunc   ;==>_Check

 

1 person likes this

“The world won’t care about your self-esteem. The world will expect you to accomplish something Before you feel good about yourself.”

Share this post


Link to post
Share on other sites
On 5/19/2016 at 10:47 PM, Trong said:

awesome, thank you, I"m using ONevent tho. I really appreciate what you did the error checking for the Service Control.  I'll update my code and see if I can implement the check feature using Onevent (I am using 

 also, I"m also running AutoITstudio  for the GUI in a separate file.  Sorry for not including the GUI.  

I'll keep you posted :) thanks again. 

On 5/19/2016 at 10:47 PM, Trong said:
Global $hForm = GUICreate("PC Status", 340, 90)
GUICtrlCreateLabel("PC: ", 24, 16, 32, 17)
Global $cSMS = GUICtrlCreateCheckbox("SMS", 16, 48, 46, 17)
Global $cMSI = GUICtrlCreateCheckbox("MSI", 64, 48, 46, 17)
Global $cCMD = GUICtrlCreateCheckbox("CMD", 112, 48, 46, 17)
Global $cBAT = GUICtrlCreateCheckbox("BAT", 160, 48, 46, 17)
Global $cREG = GUICtrlCreateCheckbox("REG", 208, 48, 46, 17)
Global $PC = GUICtrlCreateInput(@IPAddress1, 56, 16, 185, 21)
Global $CheckPC = GUICtrlCreateButton("Check", 256, 16, 73, 49)
Global $cStatus = GUICtrlCreateLabel("", 8, 72, 324, 17, BitOR(0x1, 0x0200))
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $CheckPC
            _CheckPC_Status(GUICtrlRead($PC))
    EndSwitch
    Sleep(10)
WEnd

Func _CheckPC_Status($sPC_Name)
    If StringStripWS($sPC_Name, 9) = "" Then Return SetError(1, 0, 0)
    Local $Sccm_PROMPTcheck, $sMSIcheck, $sCMDcheck, $sBATCheck, $sREGcheck, $sIPAddress, $regtemp, $iPID, $sOutput
    Local $pingPC = Ping($sPC_Name, 2000)
    If $pingPC Then
        $regtemp = RegRead("\\" & $sPC_Name & "\HKLM\SOFTWARE\Microsoft\SMS\Client\Client Components\Remote Control", "Permission Required")
        If @error = 3 Or $regtemp = "" Then
            ConsoleWrite("!Unable to determine status of remote registry!!!" & @CRLF & "-Trying to start Remote Registry.... via Service Control Manager" & @CRLF)
            $iPID = Run('"' & @SystemDir & '\sc.exe" ' & "\\" & $sPC_Name & ' start RemoteRegistry', "", @SW_HIDE, 8)
            ProcessWaitClose($iPID)
            $sOutput = StdoutRead($iPID)
            If StringInStr($sOutput, "FAILED") Then
                GUICtrlSetData($cStatus, "Can't load Remote Registry !")
                ConsoleWrite("! Can't load Remote Registry !" & @CRLF)
                Return SetError(2, 0, 0)
            Else
                GUICtrlSetData($cStatus, "Remote Registry loaded")
                ConsoleWrite("+Remote Registry loaded" & @CRLF)
            EndIf
        EndIf
        TCPStartup()
        $sIPAddress = TCPNameToIP($sPC_Name)
        ConsoleWrite("!IP: " & $sIPAddress & @CRLF)
        TCPShutdown()
        ConsoleWrite("-Ping Success: " & $pingPC & "ms" & @CRLF)
        $Sccm_PROMPTcheck = RegRead("\\" & $sPC_Name & "\HKLM\SOFTWARE\Microsoft\SMS\Client\Client Components\Remote Control", "Permission Required")
        $sMSIcheck = RegRead("\\" & $sPC_Name & "\HKEY_CLASSES_ROOT\Msi.Package\shell\runas\command", "")
        $sCMDcheck = RegRead("\\" & $sPC_Name & "\HKEY_CLASSES_ROOT\cmdfile\shell\runas\command", "")
        $sBATCheck = RegRead("\\" & $sPC_Name & "\HKEY_CLASSES_ROOT\batfile\shell\runas\command", "")
        $sREGcheck = RegRead("\\" & $sPC_Name & "\HKEY_CLASSES_ROOT\regfile\shell\runas\command", "")
        RegWrite("\\" & $sPC_Name & "\HKEY_CLASSES_ROOT\regfile\shell\runas\command", "", "REG_DWORD", 1)
        _Check($Sccm_PROMPTcheck, $cSMS)
        _Check($sMSIcheck, $cMSI)
        _Check($sCMDcheck, $cCMD)
        _Check($sBATCheck, $cBAT)
        _Check($sREGcheck, $cREG)
        ConsoleWrite("+SMS Client status: " & $Sccm_PROMPTcheck & @CRLF & "+MSI RunAS Status: " & $sMSIcheck & @CRLF & "+CMD RunAs Status: " & $sCMDcheck & @CRLF & "+BAT RunAs Status: " & $sBATCheck & @CRLF & "+REG RunAs Status: " & $sREGcheck & @CRLF & @CRLF)
        GUICtrlSetData($cStatus, "PC Status check done!")
    Else
        ConsoleWrite($sPC_Name & " is Not reachable" & @CRLF & @CRLF)
        SetError(1, 0, 0)
    EndIf
EndFunc   ;==>_CheckPC_Status

Func _Check($Data, $Control)
    If StringStripWS($Data, 8) <> "" Then
        GUICtrlSetState($Control, 1)
    Else
        GUICtrlSetState($Control, 4)
    EndIf
EndFunc   ;==>_Check

 

 

Share this post


Link to post
Share on other sites
On 5/19/2016 at 10:47 PM, Trong said:

awesome, thank you, I"m using ONevent tho. I really appreciate what you did the error checking for the Service Control.  I'll update my code and see if I can implement the check feature using Onevent (I am using 

 also, I"m also running AutoITstudio  for the GUI in a separate file.  Sorry for not including the GUI.  

I'll keep you posted :) thanks again. 

On 5/19/2016 at 10:47 PM, Trong said:
Global $hForm = GUICreate("PC Status", 340, 90)
GUICtrlCreateLabel("PC: ", 24, 16, 32, 17)
Global $cSMS = GUICtrlCreateCheckbox("SMS", 16, 48, 46, 17)
Global $cMSI = GUICtrlCreateCheckbox("MSI", 64, 48, 46, 17)
Global $cCMD = GUICtrlCreateCheckbox("CMD", 112, 48, 46, 17)
Global $cBAT = GUICtrlCreateCheckbox("BAT", 160, 48, 46, 17)
Global $cREG = GUICtrlCreateCheckbox("REG", 208, 48, 46, 17)
Global $PC = GUICtrlCreateInput(@IPAddress1, 56, 16, 185, 21)
Global $CheckPC = GUICtrlCreateButton("Check", 256, 16, 73, 49)
Global $cStatus = GUICtrlCreateLabel("", 8, 72, 324, 17, BitOR(0x1, 0x0200))
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $CheckPC
            _CheckPC_Status(GUICtrlRead($PC))
    EndSwitch
    Sleep(10)
WEnd

Func _CheckPC_Status($sPC_Name)
    If StringStripWS($sPC_Name, 9) = "" Then Return SetError(1, 0, 0)
    Local $Sccm_PROMPTcheck, $sMSIcheck, $sCMDcheck, $sBATCheck, $sREGcheck, $sIPAddress, $regtemp, $iPID, $sOutput
    Local $pingPC = Ping($sPC_Name, 2000)
    If $pingPC Then
        $regtemp = RegRead("\\" & $sPC_Name & "\HKLM\SOFTWARE\Microsoft\SMS\Client\Client Components\Remote Control", "Permission Required")
        If @error = 3 Or $regtemp = "" Then
            ConsoleWrite("!Unable to determine status of remote registry!!!" & @CRLF & "-Trying to start Remote Registry.... via Service Control Manager" & @CRLF)
            $iPID = Run('"' & @SystemDir & '\sc.exe" ' & "\\" & $sPC_Name & ' start RemoteRegistry', "", @SW_HIDE, 8)
            ProcessWaitClose($iPID)
            $sOutput = StdoutRead($iPID)
            If StringInStr($sOutput, "FAILED") Then
                GUICtrlSetData($cStatus, "Can't load Remote Registry !")
                ConsoleWrite("! Can't load Remote Registry !" & @CRLF)
                Return SetError(2, 0, 0)
            Else
                GUICtrlSetData($cStatus, "Remote Registry loaded")
                ConsoleWrite("+Remote Registry loaded" & @CRLF)
            EndIf
        EndIf
        TCPStartup()
        $sIPAddress = TCPNameToIP($sPC_Name)
        ConsoleWrite("!IP: " & $sIPAddress & @CRLF)
        TCPShutdown()
        ConsoleWrite("-Ping Success: " & $pingPC & "ms" & @CRLF)
        $Sccm_PROMPTcheck = RegRead("\\" & $sPC_Name & "\HKLM\SOFTWARE\Microsoft\SMS\Client\Client Components\Remote Control", "Permission Required")
        $sMSIcheck = RegRead("\\" & $sPC_Name & "\HKEY_CLASSES_ROOT\Msi.Package\shell\runas\command", "")
        $sCMDcheck = RegRead("\\" & $sPC_Name & "\HKEY_CLASSES_ROOT\cmdfile\shell\runas\command", "")
        $sBATCheck = RegRead("\\" & $sPC_Name & "\HKEY_CLASSES_ROOT\batfile\shell\runas\command", "")
        $sREGcheck = RegRead("\\" & $sPC_Name & "\HKEY_CLASSES_ROOT\regfile\shell\runas\command", "")
        RegWrite("\\" & $sPC_Name & "\HKEY_CLASSES_ROOT\regfile\shell\runas\command", "", "REG_DWORD", 1)
        _Check($Sccm_PROMPTcheck, $cSMS)
        _Check($sMSIcheck, $cMSI)
        _Check($sCMDcheck, $cCMD)
        _Check($sBATCheck, $cBAT)
        _Check($sREGcheck, $cREG)
        ConsoleWrite("+SMS Client status: " & $Sccm_PROMPTcheck & @CRLF & "+MSI RunAS Status: " & $sMSIcheck & @CRLF & "+CMD RunAs Status: " & $sCMDcheck & @CRLF & "+BAT RunAs Status: " & $sBATCheck & @CRLF & "+REG RunAs Status: " & $sREGcheck & @CRLF & @CRLF)
        GUICtrlSetData($cStatus, "PC Status check done!")
    Else
        ConsoleWrite($sPC_Name & " is Not reachable" & @CRLF & @CRLF)
        SetError(1, 0, 0)
    EndIf
EndFunc   ;==>_CheckPC_Status

Func _Check($Data, $Control)
    If StringStripWS($Data, 8) <> "" Then
        GUICtrlSetState($Control, 1)
    Else
        GUICtrlSetState($Control, 4)
    EndIf
EndFunc   ;==>_Check

 

 

Share this post


Link to post
Share on other sites
On 5/18/2016 at 8:03 PM, spudw2k said:

It's a little confusing.  I don't see any checkboxes in your snippet above.  I see your arrays which you are filling with zeros.  

I think know where you're going with this, but the execution isn't quite right.  

When you are doing your RegReads to update the *check variables, are you expecting that the arrays are being updated?  It doesn't work that way.  

I'd recommend something like this (apologies if this isn't the direction you wanted to take and this just added confusion)
 

;...
;Create Enumerated Variables - Human Friendly Array Indexes ;)
Local Enum $Run_as_MSIcheck, $Run_as_CMDcheck, $Run_as_BATCheck, $Run_as_REGcheck
;Create Array
Local $RUNas_chks[4]
;...
;Read Registry Values into Array
$RUNas_chks[$Run_as_MSIcheck] =  RegRead("\\" & $PC_select_Data & "\HKEY_CLASSES_ROOT\Msi.Package\shell\runas\command", "")  ; MSI access Check
$RUNas_chks[$Run_as_CMDcheck] =  RegRead("\\" & $PC_select_Data & "\HKEY_CLASSES_ROOT\cmdfile\shell\runas\command", "")  ; CMS access Check
$RUNas_chks[$Run_as_BATCheck] =  RegRead("\\" & $PC_select_Data & "\HKEY_CLASSES_ROOT\batfile\shell\runas\command", "")  ; BAT access Check
$RUNas_chks[$Run_as_REGcheck] =  RegRead("\\" & $PC_select_Data & "\HKEY_CLASSES_ROOT\regfile\shell\runas\command", "")  ; REG access Check
;...etc.

 

I might use your Array idea, the GUI are in the separate file, I forgot to include those. 

Share this post


Link to post
Share on other sites

WORKS PERFECT MAN!   so simple now that I see it.   

Share this post


Link to post
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

  • Similar Content

    • Em4gdn1m
      By Em4gdn1m
      Hey everyone, I'm curious if there is a way to incorporate a checkbox with a combo GUICtrl?
      so for instance I have a GUI that has a bunch of checkboxes that allow me to open certain programs as needed.  (this is just some parsing of my code, sorry, noob here and not sure what the preferred method of displaying code is, please enlighten me)

          $L0742 = GUICtrlCreateCheckbox("L07 4.2", 110, 320, 100)
          $L07502 = GUICtrlCreateCheckbox("L07 5.0.2", 110, 350, 100)
          $GenComm = GUICtrlCreateCheckbox("GenComm", 110, 380, 100)
          $Templates = GUICtrlCreateCheckbox("Templates", 110, 410, 100)
          $MCT = GUICtrlCreateCheckbox("MCT", 110, 440, 100)
          $Desktop_Shortcuts = GUICtrlCreateCheckbox("Desktop Shortcuts by Tester", 110, 470, 200)
       
      ...
      Case $msg = $RunBtn
                  RunPrograms()
       
      ...
      Func RunPrograms()

          if GUICtrlRead($L0742) = $GUI_CHECKED then Run("C:\Program Files\Varian\Paxscan\L07 Rel4.2\viva\viva.exe", "")
          if GUICtrlRead($L07502) = $GUI_CHECKED then Run("C:\Program Files\Varian\Paxscan\L07 Rel5\viva\viva.exe", "")
          if GUICtrlRead($GenComm) = $GUI_CHECKED then Run("\\Fpanelfs1\FPShared\Desktop_Shortcuts_by_Tester\Matt\CPI Generator\CPI Generator Windows 7 64 Bit\GenComm\GenComm.NET.exe", "")
          if GUICtrlRead($Templates) = $GUI_CHECKED then ShellExecute("\\Fpanelfs1\FPProjects\Documentation Controlled\Test_Templates")
          if GUICtrlRead($MCT) = $GUI_CHECKED then Run("\\Fpanelfs1\FPProjects\Documentation Controlled\Manufacturing Software\MCT\MCT.exe","")
          if GUICtrlRead($Desktop_Shortcuts) = $GUI_CHECKED then ShellExecute("\\Fpanelfs1\fpshared\Desktop_Shortcuts_by_Tester")
      EndFunc
       
      so i click some checkboxes, and hit a run button and the programs which are checked run, great.
      BUT i want to add a bunch of options under one checkbox. A combo that will list a bunch of versions of a program that can be opened. something like this... but I want that program to be part of a checkbox
      $ViVAComboBox = GUICtrlCreateCombo("L01 Rel 13", 110, 320, 100)
      GUICtrlSetData($ViVAComboBox, "L04|L05|L07 Rel 4.2|L07 Rel 5.0.2|L09", "L07 Rel 4.2")
       
      is this possible? is there another GUICtrl that does this better that i am not aware of?
       
       
    • crushyna
      By crushyna
      Hi everyone!
      I'm developing small testing tool for new software in my company.
      Tool itself is working correctly (it follows scripted test commands one by one), but I'm trying to develop an error checking function.

      Mechanics are simple: every time software (external) shows specific error (via window class), program asks for next step. Continue, or abort test (and return to main GUI)?
      The error check function is switched on/off via Checkbox in GUI.

      Here are some code fragments:

      Checkbox:
      Global $idCheckbox1 = GUICtrlCreateCheckbox("Enable TP.net error handling", 352, 40, 249, 17) GUICtrlSetFont(-1, 12, 400, 0, "Calibri") GUICtrlSetColor(-1, 0x000000)  
      Checkbox switch:
      GUISetState(@SW_SHOW) Local $Choosen While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idCheckbox1 If _IsChecked($idCheckbox1) Then $cSwitch1 = 1 Else $cSwitch1 = 0 EndIf Case $idAddTest (and so on...)  
      Function call:
      (alot of ElseIf commands...) ElseIf $aItem = $idOperatorIn Then WywolanieOkna() WinActivate($hFSO) ControlClick($hFSO, "", "[NAME:lblCashierNumber]") Sleep($Sleep_05) Send("0000019{Enter}19{Enter 2}") Sleep($Sleep_75) EndIf #EndRegion ### START ELSEIF ARMY ### Next If $cSwitch1 = 1 Then MsgBox( 0, "Error check!", "Error check ON!") /// just for testing purposes CheckError() Else Return EndIf EndSwitch WEnd
      Classic _IsChecked function:
      Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked  
      And Checkerror() function itself:
      Func CheckError() Local $Answer If ControlCommand($hMsgPanel, "", "[NAME:panelMsgBox]", "IsEnabled", "") Then ;~ Sleep($Sleep_05) $Answer = MsgBox(52, "Error!", "An error occured! Continue testing?") ;~ Sleep($Sleep_05) Switch $Answer Case 6 MsgBox(0, "Error!", "Test will now continue.", 3) Send("{Enter}") WinActivate($hWnd) Return Case 7 MsgBox(64, "Error!", "Test cancelled.", 5) $ElseIfArmyOff = 1 ControlClick($hMsgPanel, "", "[NAME:cmdOK]") WinActivate($AppName) #cs MsgBox( 0, "test1", $idTSList) Local $idTSListCopy For $i = 0 to _GUICtrlListView_GetItemCount($idTSList) - 1\ #ce $idTSListCopy = _GUICtrlListView_GetItemTextString($idTestCaseList, $LoopCount) ExitLoop EndSwitch EndIf Return 1 EndFunc ;==>CheckError
      Problem is: i can't make this function (CheckError() ) return to main gui state, that means: break the If/ElseIf loop.
      The switch is working correctly (MsgBox on error shows only when it's activated).
      Checkerror() function works correctly - recognizes the error, stops script until decision is made. But it doesn't terminate If/ElseIf loop.

      Any help appreciated!
    • damon
      By damon
      I am having an issue with windows 10 and regwrite.  when i run my script it acts as though it has updated the registry but when i view the registry it has not updated the keys.  I added error checking to the script but it is not showing errors.  now if i remove #requireadmin i will get error 1 - unable to open requested key.
      her is my code.
       
      #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <Process.au3> ; Declared Variables Global $userName = "user" Global $userPassword = "Ktesting" Global $autologin = "1" Global $notification = "0" Global $balloon = "0" If @OSArch = "X64" Then Global $HKLM = "HKLM64" Else Global $HKLM = "HKLM" EndIf ; Looks for switch on program start If $CmdLine[0] > 0 Then ; looks for switch on startup If $CmdLine[1] = "/boot" Then BootMachine() Else MachineInstallation() EndIf ; Setup Kiosk for first time Func MachineInstallation() #RequireAdmin MsgBox (1, "Installation", "Starting Install") ; Add Program to Run registry Key RegWrite ($HKLM & "\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "DL Kiosk", "REG_SZ", "c:\temp\DL Testing Kiosk\dl testing kiosk.exe /boot") If @error Then MsgBox (1, "error", @error) EndIf ; Add Automatic Logon Registry Key RegWrite ($HKLM & "\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon", "AutoAdminLogon", "REG_SZ", $autologin) If @error Then MsgBox (1, "error", @error) EndIf RegWrite ($HKLM & "\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon", "DefaultUserName", "REG_SZ", $userName) If @error Then MsgBox (1, "error", @error) EndIf RegWrite ($HKLM & "\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon", "DefaultPassword", "REG_SZ", $userPassword) If @error Then MsgBox (1, "error", @error) EndIf ; Pop Ups and Notification Center Registry RegWrite ("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer", "DisableNotificationCenter", "REG_SZ", $notification) If @error Then MsgBox (1, "error", @error) EndIf RegWrite ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "EnableBalloonTips", $balloon) If @error Then MsgBox (1, "error", @error) EndIf MsgBox (1, "Installation", "Install completed") EndFunc Exit  
      EDIT:
      i think i figured out my problem.  I was missing the space between Windows and NT.  user error, sorry.  
    • ruslanas402
      By ruslanas402
      Hello everyone, don't even know how to ask.  My code is:
      #include <String.au3> #include <IE.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 700, 500, 192, 124) $Button1 = GUICtrlCreateButton("View", 576, 24, 89, 41) Global $oIE = _IECreate("https://www.youtube.com/playlist?list=PL4Jcq5zn02jKpjX0nqI1_fS7mEEb5tw6z", 1, 1, 0) Sleep(1000) Global $sHTML = _IEDocReadHTML($oIE) $FirstChunks = _StringBetween($sHTML, 'pl-video-title-link yt-uix-tile-link yt-uix-sessionlink', '<div class="pl-video-owner') $x = 16 For $a In $FirstChunks $actualdata = _StringBetween($a, '">', '</a>') ;$actualdata2 = _StringBetween($a, 'href="', '&amp;') $Checkbox1 = GUICtrlCreateCheckbox($actualdata[0], 24, $x, 500, 17) $x = $x + 20 Next GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Somehow I need to open webpages where checkbox is checked by presing button view, I think I need somehow asign $actualdata with $actualdata2. Any ideas would be very appreciated
    • Leo1906
      By Leo1906
      Hello guys,
      I'm having a problem right here ..
      I was trying to create a few Registry Values using autoit, but it seems to me that Autoit can't write those values to this specific part of the registry ..
      Here is the code I'm trying to run:
      RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\test\command", "", "REG_SZ", "C:\test\convert.exe %1 geojson|convert") I'm definitly sure that the path is correct. Script is runned with Admin Rights. Everything's fine here.
      It's possible to read other values stored by Windows in this directory:
      MsgBox(0, 0, RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Windows.burn", "Description")) But you can't edit those using Autoit. I don't know what this is. In my eyes it's an Autoit Bug or something like that ...
      Possible solution for me is to write a ".reg" file and run it afterwards, but this is an unclean method I don't really want to use ..
      Any suggestions on this?
       
      Edit: the OS is Windows 7 x64 German Language btw ..