Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Stumped on adding custom button to MsgBox

$
0
0

I have a script that captures all relevant user and system information into a single pop-up screen that can be referenced easily by our helpdesk personnel to save time on information gathering.
 
I have been asked to add a second option to the screen that will give the customer the option to reboot their system.  For the life of me, I cannot make that work in an acceptable way.  I have tried GUI options to replicate my existing functionality until I've gone cross-eyed, and I cannot seem to figure out how the frack to just add this button and leave everything else in my script operational.
 
Here is the basic script:

Plain Text         
Global $strComputer Global $strlist Global $collection Global $objWMI $strComputer="." $strlist="" $objWMI = ObjGet("winmgmts:\\.\root\cimv2") $collection = $objWMI.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE") $colSMBIOS = $objWMI.ExecQuery ("Select * from Win32_SystemEnclosure") $strlist="Computername: " & @TAB & @ComputerName & @CRLF $strlist=$strlist & "Username: " & @TAB & @UserName & @CRLF $strlist=$strlist & "Operating System: " & @TAB & @OSVersion & @CRLF $strlist=$strlist & "OS Patch: " & @TAB  & @TAB & @OSServicePack & @CRLF For $objSMBIOS in $colSMBIOS  $SN = $objSMBIOS.SerialNumber Next $strlist=$strlist & "Serial or Service Tag: " & @TAB & $SN & @CRLF & @CRLF For $obj In $collection  $AdapterName = $obj.Description  $IP = $obj.IPAddress  $DNS = $obj.DNSServerSearchOrder     $Gateway = $obj.DefaultIPGateway  Next   $strlist=$strlist & $AdapterName & @CRLF $strlist=$strlist & "  IP Address: " & @TAB & $IP[0] & @CRLF $strlist=$strlist & "  DNS Server 1: " & @TAB & $DNS[0] & @CRLF $strlist=$strlist & "  DNS Server 2: " & @TAB & $DNS[1] & @CRLF $strlist=$strlist & "  Gateway: " & @TAB & $Gateway[0] & @CRLF $result = MsgBox(0,"System Information", $strlist)  

I tried replacing $result with this, but it's too easy for the user to reboot unintentionally:

$result = MsgBox(68,"System Information", $strlist & @CRLF & "" & @CRLF & "Do you want to reboot this terminal?",0) switch $result  case 6 ;YES  Run("shutdown -r -f -t 0")  case 7 ;NO  Exit endswitch  

What I would like to do is have a separate Reboot? button with a verification pop-up injected right above the OK button - but as soon as I interject any GUI elements at all, I can no longer get it to properly output the massive contents of $strlist.  Here's the most recent variation I tried before surrendering:

$winders = GUICreate ("System Information") GUISetState(@SW_SHOW) GUICtrlSetData($strlist, -1 , -1) $doReboot = GUICtrlCreateButton("Reboot?", -1 , -1) GUICtrlSetOnEvent($doReboot, "Choice_Reboot") $doneNow = GUICtrlCreateButton ("OK", -1 , -1) GUICtrlSetOnEvent($doneNow, "Done_Now")   While 1     Sleep(10)   WEnd

This gave me a blank window with working buttons, but $strlist was nowhere to be found.

 

Any help would be greatly appreciated.

 

 

 

 


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>