
Rijswijker
Active Members-
Posts
24 -
Joined
-
Last visited
Profile Information
-
Location
The Netherlands
Recent Profile Visitors
119 profile views
Rijswijker's Achievements

Seeker (1/7)
0
Reputation
-
Thanks the application is working when i run it on the SQL Server it self. The tool should be running on the server it self so the problem is solved for now. However, I still have a question, how can I find out which driver is using the SQL Server? I now use the Driver "SQL Server Native Client 11.0", and I can connect from the server itself. But from a remote computer I can not connect to the SQL Server using the same driver, how could that be? Maybe the (small) difference in the versions? I am not really at home in this, but how can you update a driver or install it on the client? Is this only possible to install an SQL Server on the client? I hope you can answer my questions, thanks in advance!
-
I still get no database connection, here the part of my code. Code: Local $sDriver = 'SQLNCLI' Local $sDatabase = 'PARK_DB' Local $sServer = '172.16.240.148' Local $sUser = 'administrator' Local $sPassword = 'password' ; Local $sConnectionString = 'DRIVER={' & $sDriver & '};SERVER=' & $sServer & ';DATABASE=' & $sDatabase & ';UID=' & $sUser & ';PWD=' & $sPassword & ';' ; 2nd attempt Local $sConnectionString = 'PROVIDER={' & $sDriver & '};SERVER=' & $sServer & ';DATABASE=' & $sDatabase & ';UID=' & $sUser & ';PWD=' & $sPassword & ';' ; Create connection object Local $oConnection = _ADO_Connection_Create() ; Open connection with $sConnectionString _ADO_Connection_OpenConString($oConnection, $sConnectionString) Error(s): ############################### ADO.au3 (769) : ==> COM Error intercepted ! $oADO_Error.description is: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified $oADO_Error.windescription: Exception occurred. $oADO_Error.number is: 80020009 $oADO_Error.lastdllerror is: 0 $oADO_Error.scriptline is: 769 $oADO_Error.source is: Microsoft OLE DB Provider for ODBC Drivers $oADO_Error.helpfile is: $oADO_Error.helpcontext is: 0 ############################### 2nd attempt ############################### ADO.au3 (769) : ==> COM Error intercepted ! $oADO_Error.description is: Provider cannot be found. It may not be properly installed. $oADO_Error.windescription: Exception occurred. $oADO_Error.number is: 80020009 $oADO_Error.lastdllerror is: 0 $oADO_Error.scriptline is: 769 $oADO_Error.source is: ADODB.Connection $oADO_Error.helpfile is: C:\Windows\HELP\ADO270.CHM $oADO_Error.helpcontext is: 1240655 ###############################
-
I tried now, but i get an error: ############################### ADO.au3 (769) : ==> COM Error intercepted ! $oADO_Error.description is: [Microsoft][ODBC SQL Server Driver][DBNETLIB]SSL Security error $oADO_Error.windescription: Exception occurred. $oADO_Error.number is: 80020009 $oADO_Error.lastdllerror is: 0 $oADO_Error.scriptline is: 769 $oADO_Error.source is: Microsoft OLE DB Provider for ODBC Drivers $oADO_Error.helpfile is: $oADO_Error.helpcontext is: 0 ############################### Is the SQL driver to old from the Autoit engine?
-
Hi, I am not able to execute the following sql query. _SQL_Execute(-1,"INSERT INTO KKSPERRE (HashNr, TeilKkNr, KkSperrbehandlung, KkGes) VALUES('1234', CONVERT(varbinary, '12345678901234'), 0, 'VIEL')") I get the error. "C:\Users\Administrator\Desktop\_sql.au3" (402) : ==> The requested action with this object has failed.: $hQuery = $hConHandle.Execute($vQuery) $hQuery = $hConHandle^ ERROR I think the issue is in the CONVERT() part, i am not able to test it without the convert part because it is an existing running database. If i run the query in the SQL Management Studio the query is executing fine. How can i solve this with this library? Thanks in advance
-
Read application.exe.config (XML)
Rijswijker replied to Rijswijker's topic in AutoIt General Help and Support
nobody? -
Hi, I am struggling with reading a configuration file. What i try to achieve is an array with two columns: Column 0: Name of the value for ex. UserName Column 1: the value <value></value> : MyUsername The application.exe.config file <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > <section name="IbUpload.Agent.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> </sectionGroup> </configSections> <startup> <supportedRuntime version="v4.0"/> <supportedRuntime version="v2.0.50727"/> </startup> <applicationSettings> <IbUpload.Settings> <setting name="WebServerUrl" serializeAs="String"> <value>https://www.domain.com/xss/discovery/webservice</value> </setting> <setting name="DiarFileName" serializeAs="String"> <value>%FacilityNo% - %CaptureDateTime%</value> </setting> <setting name="UserName" serializeAs="String"> <value>Username</value> </setting> <setting name="Password" serializeAs="String"> <value>Password</value> </setting> <setting name="ClientName" serializeAs="String"> <value>APT.%FacilityNo%</value> </setting> <setting name="UpdateUrl" serializeAs="String"> <value>https://updateserver.domain.com/release</value> </setting> </IbUpload.Settings> </applicationSettings> </configuration> I have a working solution but i want to extend the flexibility of the function. Now i have to know all the setting names, ; Read value Local $sAppCfgUserName = _ApplicationConfig("Application.exe.config", "UserName") Local $sAppCfgPassword = _ApplicationConfig("Application.exe.config", "Password") ; Write value _ApplicationConfig("Application.exe.config", "UserName", "NewUsername") _ApplicationConfig("Application.exe.config", "Password", "NewPassword") #Region Read or Write to Application.Config.exe Func _ApplicationConfig($sFile, $sXmlKeyName, $sXmlValue = Null) Local $aFile, $rReturn = False ; Check if configuration file exists, if not set @error to 1 If Not FileExists($sFile) Then SetError(1) ; File does not exist Return False EndIf ; Read config If Not($sXmlValue) Then Local $oXML = ObjCreate("Microsoft.XMLDOM") If IsObj($oXML) Then $oXML.load($sFile) $oParameters = $oXML.SelectNodes("//IbUpload.Settings/setting[@name='" & $sXmlKeyName & "']") For $oParameter In $oParameters $oValue = $oParameter.SelectSingleNode("./value") Return String($oValue.text) ; Return value Next Else MsgBox(0,0,2) SetError(2, @error) ; Error creating object Return "" EndIf Else ; Write Config $sXmlSearchValue = _ApplicationConfig($sFile, $sXmlKeyName) _FileReadToArray($sFile, $aFile) If @error Then MsgBox(0,0,3) SetError(3, @error) Return False EndIf For $a = 1 To $aFile[0] If StringInStr($aFile[$a], '<value>' & $sXmlSearchValue & '</value>') Then $sText = StringReplace(FileReadLine($sFile, $a), $sXmlSearchValue, $sXmlValue) _FileWriteToLine($sFile, $a, $sText, 1) If Not @error Then Return True EndIf Next Return $rReturn EndIf EndFunc ;==> _ApplicationConfig #EndRegion In the end i want to compare two configuration files, now i have to know all "ParentNode" names and i am not able to check if there more Nodes in one of the two configuration files. For example, one configuration file has the setting UpdateUrl2, i want able to detect that change. <setting name="UpdateUrl2" serializeAs="String"> <value>https://updateserver.domain.com/pub/software/release</value> </setting>
-
Hi, I'm currently struggling with a piece of code. Func _WMI_Win32_Process($sWorkingDirectory = Null) Global $sApplication, $intProcessID Local $i = 0 Local $aErr[1][2] = [[0, 0]] If $sComputer & $sUser & $sPassword = "." Then ; Localhost ToolTip("...ObjGet", @DesktopWidth - 30,@DesktopHeight - 130, "Win32_Process",1,4) Global $oWMIService = ObjGet("winmgmts:\\" & $sComputer & "\root\CIMV2") If Not IsObj($oWMIService) Then Return SetError(2, 99, $aErr) Else ToolTip("...ObjCreate", @DesktopWidth - 30,@DesktopHeight - 130, "Win32_Process",1,4) Local $wmiLocator = ObjCreate("WbemScripting.SWbemLocator") If Not IsObj($wmiLocator) Then Return SetError(3, 99, $aErr) ToolTip("...ConnectServer", @DesktopWidth - 30,@DesktopHeight - 130, "Win32_Process",1,4) Global $oWMIService = $wmiLocator.ConnectServer($sComputer, "\root\CIMV2", $sUser, $sPassword) If Not IsObj($oWMIService) Then Return SetError(4, 99, $aErr) EndIf ToolTip("...ExecQuery", @DesktopWidth - 30,@DesktopHeight - 130, "Win32_Process",1,4) Local $objStartup = $oWMIService.Get("Win32_ProcessStartup") Local $objConfig = $objStartup.SpawnInstance_ Local $Security = $oWMIService.Security_ $Security.ImpersonationLevel = 3 Local $oWMIClass = $oWMIService.Get("Win32_Process") Local $sReturn = $oWMIClass.Create($sApplication, NULL, $objConfig, $intProcessID) ;no working directory specified Return($intProcessID) EndFunc ;==>_WMI_Win32_Process Func _WMI_CheckExitCode() Global $oWMIService, $intProcessID Local $i = 0 ToolTip("...Process is Running" & @CRLF & " PID: " & $intProcessID, @DesktopWidth - 30,@DesktopHeight - 130, "Win32_Process",1,4) Local $colProcessStopTrace = $oWMIService.ExecNotificationQuery("SELECT * FROM Win32_ProcessStopTrace") Do Local $objLatestEvent = $colProcessStopTrace.NextEvent(1) If $objLatestEvent.ProcessId = $intProcessID Then $i = 1 Until $i = 1 SetError($objLatestEvent.ExitStatus) EndFunc ;==>_WMI_CheckExitCode What i want is get the ExitCode of the ended proces, but i get not always the ExitCode if the process has ended (For example: Two processes end at the same time). Is it possible to Query the ExitCode in another way than use the Win32_ProcessStopTrace and the $colProcessStopTrace.NextEvent? The WMI Command is running on a remote machine. Is there a way to request the ExitCodes from a process that had running in the past using the PID on a remote machine? Thanks in advance.
-
- wmi
- win32_processstoptrace
-
(and 1 more)
Tagged with:
-
Hi i am struggling with a script, I want to run a SQL script on multiple machines. What i do now is, copy a *.sql file to the target machine and run it with SQLCMD and write the output to a result file and copy the result file back to my machine. What i want is: I make a SQL Connection to the target machine and run the selected *.sql script directly without copying it. But, i want only the result of the PRINT jobs in the script. For example: (the content of the .sql script) PRINT 'Start' PRINT '-----------------------------------------------------------------------------------------------------------------------------' PRINT 'Facility Name: ' + @ges PRINT 'Release/Version: ' + @rel + '.' + @upd + '.' + @rev PRINT 'Hotfix: ' + @HFName PRINT '----------------------------------------------' PRINT '' BEGIN PRINT '' PRINT 'affected keydetectors for 125 KHz cards' PRINT '==========================================================' PRINT '' SELECT GER.GerNr AS 'DeviceNo', GER.GerBez AS 'DeviceDesignation', GER.GerKbez AS 'DeviceAbbreviation', KOMPONENTE.Info AS 'Info' FROM GER, KOMPONENTE WHERE GER.GerNr = KOMPONENTE.GerNr AND GER.IstNichtVorhanden = 0 AND ( KOMPONENTE.Info LIKE '%VKM%' OR KOMPONENTE.Info LIKE '%VKX%') ORDER BY GER.GerNr END How can i do this?
-
I am almost there where i want to be. The only problem is read-out the file and update the values in the input boxes (Get current button) #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <Array.au3> #include <File.au3> Global $aoLabels[19],$aoInputs[19] Global $traceLevels[] = ['MAIN', 'EMMAIN', 'KEYDETECTOR', 'PRINTATHOME', 'OEMREADER', 'BARRIER', 'CODER', 'IO', 'SCREEN', 'SIOPORT', 'SERIALPORT', 'USB', 'THREADING', 'TIMER', 'ETHERNET', 'SERVICETOOL', 'SDSERIAL'] #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("SET TRACE LEVELS", 300, (UBound($traceLevels)*25)+70, 400, 450) Global $sFileProperties="TraceLevels.Properties" Local $sLine="" Local $sName="" For $i=0 to UBound($traceLevels)-1 $aoLabels[$i] = GUICtrlCreateLabel($traceLevels[$i], 10, 15+(25*$i), 140, 17) $aoInputs[$i]= GUICtrlCreateInput("0", 150, 13+(25*$i), 35, 20) GUICtrlCreateUpdown($aoInputs[$i]) GUICtrlSetLimit(-1, 8, 0) Next $fileCountLabel = GUICtrlCreateLabel("MAX_TRACE_FILE_COUNT", 10, 15+(25*$i), 150, 17) $fileCountInput = GUICtrlCreateInput("0", 150, 13+(25*$i), 35, 20) GUICtrlCreateUpdown($fileCountInput) GUICtrlSetLimit(-1, 9, 1) $fileSizeLabel = GUICtrlCreateLabel("MAX_TRACE_FILE_SIZE", 10, 40+(25*$i), 150, 17) $fileSizeInput = GUICtrlCreateInput("0", 150, 38+(25*$i), 35, 20) GUICtrlCreateUpdown($fileSizeInput) GUICtrlSetLimit(-1, 4, 1) $Button1 = GUICtrlCreateButton("Get current", 206, 11, 83, 21) $Button2 = GUICtrlCreateButton("Set tracelevels", 206, 37, 83, 21) $Button3 = GUICtrlCreateButton("Set all to 0", 206, 63, 83, 21) $Button4 = GUICtrlCreateButton("Set all to 8", 206, 89, 83, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ;~ Get current tracelevels Local $aArray = 0 If Not _FileReadToArray(@ScriptDir & "\TraceLevels.properties", $aArray, 0, '=') Then MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file. EndIf ;~ GUICtrlSetData($MAIN, '3') ; Display the array in _ArrayDisplay. _ArrayDisplay($aArray) Case $Button2 ;~ Set tracelevels FileDelete($sFileProperties) FileWrite($sFileProperties,"# TraceLevels.Properties Example" & @CRLF) For $i=0 to UBound($traceLevels)-1 ConsoleWrite(GUICtrlRead($aoLabels[$i]) & "=" & GUICtrlRead($aoInputs[$i]) & @CRLF) FileWrite($sFileProperties,GUICtrlRead($aoLabels[$i]) & "=" & GUICtrlRead($aoInputs[$i]) & @CRLF) Next Case $Button3 ;~ Set all tracelevels to 0 FileDelete($sFileProperties) FileWrite($sFileProperties,"# TraceLevels.Properties Reset" & @CRLF) For $i=0 to UBound($traceLevels)-1 ConsoleWrite(GUICtrlRead($aoLabels[$i]) & "=0" & @CRLF) FileWrite($sFileProperties,GUICtrlRead($aoLabels[$i]) & "=0" & @CRLF) Next writeFileConditions() Case $Button4 ;~ Set all tracelevels to 8 FileDelete($sFileProperties) FileWrite($sFileProperties,"# TraceLevels.Properties Set all to 8" & @CRLF) For $i=0 to UBound($traceLevels)-1 ConsoleWrite(GUICtrlRead($aoLabels[$i]) & "=8" & @CRLF) FileWrite($sFileProperties,GUICtrlRead($aoLabels[$i]) & "=8" & @CRLF) Next writeFileConditions() EndSwitch WEnd Func writeFileConditions() Switch GUICtrlRead($fileCountInput) Case 1 to 9 FileWriteLine($sFileProperties, "MAX_TRACE_FILE_COUNT=" & GUICtrlRead($fileCountInput)) ConsoleWrite("MAX_TRACE_FILE_COUNT=" & GUICtrlRead($fileCountInput) & @CRLF) Case Else FileWriteLine($sFileProperties, "MAX_TRACE_FILE_COUNT=2") ConsoleWrite("MAX_TRACE_FILE_COUNT=2" & @CRLF) EndSwitch Switch GUICtrlRead($fileSizeInput) Case 1 to 4 FileWriteLine($sFileProperties, "MAX_TRACE_FILE_SIZE=" & GUICtrlRead($fileSizeInput)) ConsoleWrite("MAX_TRACE_FILE_SIZE=" & GUICtrlRead($fileSizeInput) & @CRLF) Case Else FileWriteLine($sFileProperties, "MAX_TRACE_FILE_SIZE=1") ConsoleWrite("MAX_TRACE_FILE_SIZE=1" & @CRLF) EndSwitch EndFuncNow i get an Array with the values, but how can i update the fields created by the script? ----- EDIT ----- Problem Solved Case $Button1 ;~ Get current tracelevels Local $aArray = 0 If Not _FileReadToArray(@ScriptDir & "\TraceLevels.properties", $aArray, 0, '=') Then MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file. EndIf For $i=0 to UBound($traceLevels)-1 $aoSearch = _ArraySearch($traceLevels, $traceLevels[$i], 0, 0, 0, 0, 1, 2) GUICtrlSetData($aoInputs[$aoSearch], $aArray[$i][1]) Next Case $Button2 ;~ Set tracelevels
-
Thanks for your help, I'll figuring it out.
-
-
Hi, Is it possible to reduce the code below? What I do now is keep repeating the same code, when creating the GUI, I always count 25 pixels down for the next line. When create the TraceLevels.properties file I check whether it meets the conditions, if not i set the tracelevel to default 0. (Checking user input) I am now 300+ lines of codes further and actually have i have nothing done yet. Later when the script is finally off and I continue this way I'm on the thousands of lines of code. That is not what i want. Is it possible to create a function with an Array or something like that for doing the same? And what is the best way to read TraceLevels.properties without doing the same thing multiple times? (Read the values of the TraceLevels.properties file and write the values to the correct inputbox). #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> Local $traceLevels[] = ['MAIN', 'EMMAIN', 'KEYDETECTOR', 'PRINTATHOME', 'OEMREADER', 'BARRIER', 'CODER', 'IO', 'SCREEN', 'SIOPORT', 'SERIALPORT', 'USB', 'THREADING', 'TIMER', 'ETHERNET', 'SERVICETOOL', 'SDSERIAL'] ;~ _ArrayDisplay($traceLevels) #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("SET TRACE LEVELS", 300, 495, 1064, 450) $Label1 = GUICtrlCreateLabel("MAIN", 10, 15, 150, 17) Local $MAIN = GUICtrlCreateInput("0", 150, 13, 35, 20) $Level1 = GUICtrlCreateUpdown($MAIN) GUICtrlSetLimit($Level1, 8, 0) $Label2 = GUICtrlCreateLabel("EMMAIN", 10, 40, 150, 17) Local $EMMAIN = GUICtrlCreateInput("0", 150, 37, 35, 20) $Level2 = GUICtrlCreateUpdown($EMMAIN) GUICtrlSetLimit($Level2, 8, 0) $Label3 = GUICtrlCreateLabel("KEYDETECTOR", 10, 65, 150, 17) Local $KEYDETECTOR = GUICtrlCreateInput("0", 150, 62, 35, 20) $Level3 = GUICtrlCreateUpdown($KEYDETECTOR) GUICtrlSetLimit($Level3, 8, 0) $Label4 = GUICtrlCreateLabel("PRINTATHOME", 10, 90, 150, 17) Local $PRINTATHOME = GUICtrlCreateInput("0", 150, 87, 35, 20) $Level4 = GUICtrlCreateUpdown($PRINTATHOME) GUICtrlSetLimit($Level4, 8, 0) $Label5 = GUICtrlCreateLabel("OEMREADER", 10, 115, 150, 17) Local $OEMREADER = GUICtrlCreateInput("0", 150, 112, 35, 20) $Level5 = GUICtrlCreateUpdown($OEMREADER) GUICtrlSetLimit($Level5, 8, 0) $Label6 = GUICtrlCreateLabel("BARRIER", 10, 140, 150, 17) Local $BARRIER = GUICtrlCreateInput("0", 150, 137, 35, 20) $Level6 = GUICtrlCreateUpdown($BARRIER) GUICtrlSetLimit($Level6, 8, 0) $Label7 = GUICtrlCreateLabel("CODER", 10, 165, 150, 17) Local $CODER = GUICtrlCreateInput("0", 150, 163, 35, 20) $Level7 = GUICtrlCreateUpdown($CODER) GUICtrlSetLimit($Level7, 8, 0) $Label8 = GUICtrlCreateLabel("IO", 10, 190, 150, 17) Local $IO = GUICtrlCreateInput("0", 150, 187, 35, 20) $Level8 = GUICtrlCreateUpdown($IO) GUICtrlSetLimit($Level8, 8, 0) $Label9 = GUICtrlCreateLabel("SCREEN", 10, 215, 150, 17) Local $SCREEN = GUICtrlCreateInput("0", 150, 212, 35, 20) $Level9 = GUICtrlCreateUpdown($SCREEN) GUICtrlSetLimit($Level9, 8, 0) $Label10 = GUICtrlCreateLabel("SIOPORT", 10, 240, 150, 17) Local $SIOPORT = GUICtrlCreateInput("0", 150, 237, 35, 20) $Level10 = GUICtrlCreateUpdown($SIOPORT) GUICtrlSetLimit($Level10, 8, 0) $Label11 = GUICtrlCreateLabel("SERIALPORT", 10, 265, 150, 17) Local $SERIALPORT = GUICtrlCreateInput("0", 150, 262, 35, 20) $Level11 = GUICtrlCreateUpdown($SERIALPORT) GUICtrlSetLimit($Level11, 8, 0) $Label12 = GUICtrlCreateLabel("USB", 10, 290, 150, 17) Local $USB = GUICtrlCreateInput("0", 150, 287, 35, 20) $Level12 = GUICtrlCreateUpdown($USB) GUICtrlSetLimit($Level12, 8, 0) $Label13 = GUICtrlCreateLabel("THREADING", 10, 315, 150, 17) Local $THREADING = GUICtrlCreateInput("0", 150, 312, 35, 20) $Level13 = GUICtrlCreateUpdown($THREADING) GUICtrlSetLimit($Level13, 8, 0) $Label14 = GUICtrlCreateLabel("TIMER", 10, 340, 150, 17) Local $TIMER = GUICtrlCreateInput("0", 150, 337, 35, 20) $Level14 = GUICtrlCreateUpdown($TIMER) GUICtrlSetLimit($Level14, 8, 0) $Label15 = GUICtrlCreateLabel("ETHERNET", 10, 365, 150, 17) Local $ETHERNET = GUICtrlCreateInput("0", 150, 362, 35, 20) $Level15 = GUICtrlCreateUpdown($ETHERNET) GUICtrlSetLimit($Level15, 8, 0) $Label16 = GUICtrlCreateLabel("SERVICETOOL", 10, 390, 150, 17) Local $SERVICETOOL = GUICtrlCreateInput("0", 150, 387, 35, 20) $Level16 = GUICtrlCreateUpdown($SERVICETOOL) GUICtrlSetLimit($Level16, 8, 0) $Label17 = GUICtrlCreateLabel("SDSERIAL", 10, 415, 150, 17) Local $SDSERIAL = GUICtrlCreateInput("0", 150, 413, 35, 20) $Level17 = GUICtrlCreateUpdown($SDSERIAL) GUICtrlSetLimit($Level17, 8, 0) $Label18 = GUICtrlCreateLabel("MAX TRACE FILE COUNT", 10, 440, 150, 17) Local $MAX_TRACE_FILE_COUNT = GUICtrlCreateInput("0", 150, 437, 35, 20) $Level18 = GUICtrlCreateUpdown($MAX_TRACE_FILE_COUNT) GUICtrlSetLimit($Level18, 9, 1) $Label19 = GUICtrlCreateLabel("MAX TRACE FILE SIZE", 10, 465, 150, 17) Local $MAX_TRACE_FILE_SIZE = GUICtrlCreateInput("0", 150, 462, 35, 20) $Level19 = GUICtrlCreateUpdown($MAX_TRACE_FILE_SIZE) GUICtrlSetLimit($Level19, 4, 1) $Button1 = GUICtrlCreateButton("Get current", 206, 11, 83, 21) $Button2 = GUICtrlCreateButton("Set tracelevels", 206, 37, 83, 21) $Button3 = GUICtrlCreateButton("Set all to 0", 206, 63, 83, 21) $Button4 = GUICtrlCreateButton("Set all to 8", 206, 89, 83, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ;~ Get current tracelevels Local $aArray = 0 If Not _FileReadToArray(@ScriptDir & "\TraceLevels.properties", $aArray, 0, '=') Then MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file. EndIf ; Display the array in _ArrayDisplay. _ArrayDisplay($aArray) Case $Button2 ;~ Set tracelevels setTraceLevels8() Case $Button3 ;~ Set all tracelevels to 0 Case $Button4 ;~ Set all tracelevels to 8 EndSwitch WEnd Func setTraceLevels8() Local const $sFilePath = @ScriptDir & "\TraceLevels.properties" FileDelete($sFilePath) Local $hFileOpen = FileOpen($sFilePath, $FO_APPEND) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.") EndIf Switch GUICtrlRead($MAIN) Case 1 to 8 FileWriteLine($hFileOpen, "MAIN=" & GUICtrlRead($MAIN)) ConsoleWrite("MAIN=" & GUICtrlRead($MAIN)) Case Else FileWriteLine($hFileOpen, "MAIN=0") ConsoleWrite("MAIN=0") EndSwitch Switch GUICtrlRead($EMMAIN) Case 1 to 8 FileWriteLine($hFileOpen, "EMMAIN=" & GUICtrlRead($EMMAIN)) ConsoleWrite("EMMAIN=" & GUICtrlRead($EMMAIN)) Case Else FileWriteLine($hFileOpen, "EMMAIN=0") ConsoleWrite("EMMAIN=0") EndSwitch Switch GUICtrlRead($KEYDETECTOR) Case 1 to 8 FileWriteLine($hFileOpen, "KEYDETECTOR=" & GUICtrlRead($KEYDETECTOR)) ConsoleWrite("KEYDETECTOR=" & GUICtrlRead($KEYDETECTOR)) Case Else FileWriteLine($hFileOpen, "KEYDETECTOR=0") ConsoleWrite("KEYDETECTOR=0") EndSwitch Switch GUICtrlRead($PRINTATHOME) Case 1 to 8 FileWriteLine($hFileOpen, "PRINTATHOME=" & GUICtrlRead($PRINTATHOME)) ConsoleWrite("PRINTATHOME=" & GUICtrlRead($PRINTATHOME)) Case Else FileWriteLine($hFileOpen, "PRINTATHOME=0") ConsoleWrite("PRINTATHOME=0") EndSwitch Switch GUICtrlRead($OEMREADER) Case 1 to 8 FileWriteLine($hFileOpen, "OEMREADER=" & GUICtrlRead($OEMREADER)) ConsoleWrite("OEMREADER=" & GUICtrlRead($OEMREADER)) Case Else FileWriteLine($hFileOpen, "OEMREADER=0") ConsoleWrite("OEMREADER=0") EndSwitch Switch GUICtrlRead($BARRIER) Case 1 to 8 FileWriteLine($hFileOpen, "BARRIER=" & GUICtrlRead($BARRIER)) ConsoleWrite("BARRIER=" & GUICtrlRead($BARRIER)) Case Else FileWriteLine($hFileOpen, "BARRIER=0") ConsoleWrite("BARRIER=0") EndSwitch Switch GUICtrlRead($CODER) Case 1 to 8 FileWriteLine($hFileOpen, "CODER=" & GUICtrlRead($CODER)) ConsoleWrite("CODER=" & GUICtrlRead($CODER)) Case Else FileWriteLine($hFileOpen, "CODER=0") ConsoleWrite("CODER=0") EndSwitch Switch GUICtrlRead($IO) Case 1 to 8 FileWriteLine($hFileOpen, "IO=" & GUICtrlRead($IO)) ConsoleWrite("IO=" & GUICtrlRead($IO)) Case Else FileWriteLine($hFileOpen, "IO=0") ConsoleWrite("IO=0") EndSwitch Switch GUICtrlRead($SCREEN) Case 1 to 8 FileWriteLine($hFileOpen, "SCREEN=" & GUICtrlRead($SCREEN)) ConsoleWrite("SCREEN=" & GUICtrlRead($SCREEN)) Case Else FileWriteLine($hFileOpen, "SCREEN=0") ConsoleWrite("SCREEN=0") EndSwitch Switch GUICtrlRead($SIOPORT) Case 1 to 8 FileWriteLine($hFileOpen, "SIOPORT=" & GUICtrlRead($SIOPORT)) ConsoleWrite("SIOPORT=" & GUICtrlRead($SIOPORT)) Case Else FileWriteLine($hFileOpen, "SIOPORT=0") ConsoleWrite("SIOPORT=0") EndSwitch Switch GUICtrlRead($SERIALPORT) Case 1 to 8 FileWriteLine($hFileOpen, "SERIALPORT=" & GUICtrlRead($SERIALPORT)) ConsoleWrite("SERIALPORT=" & GUICtrlRead($SERIALPORT)) Case Else FileWriteLine($hFileOpen, "SERIALPORT=0") ConsoleWrite("SERIALPORT=0") EndSwitch Switch GUICtrlRead($USB) Case 1 to 8 FileWriteLine($hFileOpen, "USB=" & GUICtrlRead($USB)) ConsoleWrite("USB=" & GUICtrlRead($USB)) Case Else FileWriteLine($hFileOpen, "USB=0") ConsoleWrite("USB=0") EndSwitch Switch GUICtrlRead($THREADING) Case 1 to 8 FileWriteLine($hFileOpen, "THREADING=" & GUICtrlRead($THREADING)) ConsoleWrite("THREADING=" & GUICtrlRead($THREADING)) Case Else FileWriteLine($hFileOpen, "THREADING=0") ConsoleWrite("THREADING=0") EndSwitch Switch GUICtrlRead($TIMER) Case 1 to 8 FileWriteLine($hFileOpen, "TIMER=" & GUICtrlRead($TIMER)) ConsoleWrite("TIMER=" & GUICtrlRead($TIMER)) Case Else FileWriteLine($hFileOpen, "TIMER=0") ConsoleWrite("TIMER=0") EndSwitch Switch GUICtrlRead($ETHERNET) Case 1 to 8 FileWriteLine($hFileOpen, "ETHERNET=" & GUICtrlRead($ETHERNET)) ConsoleWrite("ETHERNET=" & GUICtrlRead($ETHERNET)) Case Else FileWriteLine($hFileOpen, "ETHERNET=0") ConsoleWrite("ETHERNET=0") EndSwitch Switch GUICtrlRead($SERVICETOOL) Case 1 to 8 FileWriteLine($hFileOpen, "SERVICETOOL=" & GUICtrlRead($SERVICETOOL)) ConsoleWrite("SERVICETOOL=" & GUICtrlRead($SERVICETOOL)) Case Else FileWriteLine($hFileOpen, "SERVICETOOL=0") ConsoleWrite("SERVICETOOL=0") EndSwitch Switch GUICtrlRead($SDSERIAL) Case 1 to 8 FileWriteLine($hFileOpen, "SDSERIAL=" & GUICtrlRead($SDSERIAL)) ConsoleWrite("SDSERIAL=" & GUICtrlRead($SDSERIAL)) Case Else FileWriteLine($hFileOpen, "SDSERIAL=0") ConsoleWrite("SDSERIAL=0") EndSwitch Switch GUICtrlRead($MAX_TRACE_FILE_COUNT) Case 1 to 9 FileWriteLine($hFileOpen, "MAX_TRACE_FILE_COUNT=" & GUICtrlRead($MAX_TRACE_FILE_COUNT)) ConsoleWrite("MAX_TRACE_FILE_COUNT=" & GUICtrlRead($MAX_TRACE_FILE_COUNT)) Case Else FileWriteLine($hFileOpen, "MAX_TRACE_FILE_COUNT=2") ConsoleWrite("MAX_TRACE_FILE_COUNT=2") EndSwitch Switch GUICtrlRead($MAX_TRACE_FILE_SIZE) Case 1 to 4 FileWriteLine($hFileOpen, "MAX_TRACE_FILE_SIZE=" & GUICtrlRead($MAX_TRACE_FILE_SIZE)) ConsoleWrite("MAX_TRACE_FILE_SIZE=" & GUICtrlRead($MAX_TRACE_FILE_SIZE)) Case Else FileWriteLine($hFileOpen, "MAX_TRACE_FILE_SIZE=1") ConsoleWrite("MAX_TRACE_FILE_SIZE=1") EndSwitch ; Close the handle returned by FileOpen. FileClose($hFileOpen) ; Display the contents of the file passing the filepath to FileRead instead of a handle returned by FileOpen. MsgBox($MB_SYSTEMMODAL, "", "Contents of the file:" & @CRLF & FileRead($sFilePath)) EndFunc# First Draft Local $traceLevels[] = ['MAIN', 'EMMAIN', 'KEYDETECTOR', 'PRINTATHOME', 'OEMREADER', 'BARRIER', 'CODER', 'IO', 'SCREEN', 'SIOPORT', 'SERIALPORT', 'USB', 'THREADING', 'TIMER', 'ETHERNET', 'SERVICETOOL', 'SDSERIAL'] Local $traceLevelMax = 8 ;~ minimum 0 Local $maxTraceFileSize = 4 ;~ minimum 1 Local $maxTraceFileCount = 9 ;~ minimum 1 Func createGUI() ... EndFunc Func setTraceLevels() ... EndFunc Func getTraceLevels() ... EndFunc Func setTraceLevelsto0() ... EndFunc Func setTraceLevelsto8() ... EndFunc # TraceLevels.Properties Example MAIN=0 EMMAIN=0 KEYDETECTOR=0 PRINTATHOME=0 OEMREADER=0 BARRIER=0 CODER=0 IO=0 SCREEN=0 SIOPORT=0 SERIALPORT=0 USB=0 THREADING=0 TIMER=0 ETHERNET=5 SERVICETOOL=0 SDSERIAL=0 MAX_TRACE_FILE_COUNT=2 MAX_TRACE_FILE_SIZE=1 Thanks in advance, Sorry for my bad english..