Jump to content

donhorn20

Active Members
  • Posts

    29
  • Joined

  • Last visited

Recent Profile Visitors

110 profile views

donhorn20's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Is it possible to take the same ini file, encrypt it ahead of time via _Crypt_ EncryptFile and have my script read those encrypted section names back as plain text within the combo box?
  2. Thanks @pseakins and @Nine for all the help. @Nine code was spot on as stated. The issue was I had a typo in my test file. The files do contain the "%" but there was a space issue. Once I corrected this minor oversight on my side (thanks to @pseakins making me take a deeper look at my file), it all worked. Thanks again for the speedy help. Much appreciated.
  3. So I see what you did there with the _PathSplit and then passing that through the If StingInStr statement, but it seems to just list all my files and not display the mismatched ones Its almost like its not evaluating the sFileName within the StringInStr section. The consolewrite spits back Test1.pat Test2.pat Test3.pat and so on, even though Test1.pat should not of returned a result because its filename "Test1" matches the section within that file "%File Name:Test1".
  4. Hey guys, I have a scenario that I am trying to wrap my head around to if it's even possible to code for. Let me lay out the scenario first before I get into to far. I have multiple files with different file names. There is a particular string within each text file that references the filename itself, just without the extension. I am trying to find all text files that possibly have a different string then the filename within the file. Example of a good file: Text1.pat (string within file is labeled as %File Name:Text1) Text2.pat (string within file is labeled as %File Name:Text2) Example of a bad file that I am trying to find all instances of: Text3.pat (string within file is labeled as %File Name:Text7) I can get the list of files from an array, but am stuck on how to pass that array through a possible check so that it compares the filename to a string within that file but strips off the extension. Any help or guidance would be great. So far I just have the basic search going for the files in question (taken from help file) #include <File.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <FileConstants.au3> Test() Func Test() ; List all the files and folders in the desktop directory. Local $aFileList = _FileListToArray(@DesktopDir & "\test", "*.pat", 1, True) If @error = 1 Then MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.") Exit EndIf If @error = 4 Then MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.") Exit EndIf ; Display the results returned by _FileListToArray. _ArrayDisplay($aFileList, "$aFileList") EndFunc
  5. Trying to get this combo box drop down to read the data within my ini section names. Not able to return the key=value data when I hit the button on the gui. I can't seem to get the IniReadSection to recognize anything based off of my selection. What am I missing here? #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #Region ### START Koda GUI section ### Form= ; original script borrowed from InunoTaishou and Subz $Form1 = GUICreate("Sample", 413, 213, 192, 124) $Combo1 = GUICtrlCreateCombo("", 80, 24, 241, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $Button1 = GUICtrlCreateButton("Submit", 152, 56, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ; Get the sections of the ini file Global $iFile = @ScriptDir & "\test5.ini" Global $aSections = IniReadSectionNames($iFile) ; If the IniReadSectionNames succeeded, convert the array to a string with each item separated by a | (pipe) and set the default selected item to $aSections[1] If (Not @Error) Then GUICtrlSetData($Combo1, _ArraytoString($aSections, "|", 1), $aSections[1]) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $test = IniReadSection($iFile, $aSections) MsgBox($MB_SYSTEMMODAL, "", $test) EndSwitch WEnd I've attached my sample ini data too. test5.ini
  6. Well I looked into Scriptomatic and tried out the code you provided. It does return the drive size in bytes, but it still is the incorrect value being captured. I even tried the Win32_Volume to see if it would produce different results. But I still get the same output. Check out what I mean. Scriptomatic returns size in Bytes = 4398040765440 I convert that to MB 4398040765440 / 1048576 = 4194298.520507813 MB Notice this isn't even close to what the Windows Properties shows for this volume. As a matter of fact you get different results depending on how you look at the volume. Ultimately I need to find a way to get 4095.88 GB or 4194174 MB based off of disk # selected. Right now I am not seeing an easy way of extracting that data. Have you guys seen this type of discrepancy before? Here is the code with a simple input box if you want to see your own results. #include <ButtonConstants.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <WindowsConstants.au3> Opt("GUICoordMode", 1) Opt("GUIOnEventMode", 1) ;0=disabled, 1=OnEvent mode enabled Opt("GUICloseOnEsc", 1) ;Send $GUI_EVENT_CLOSE message when ESC is pressed $GUI = GUICreate("", 175, 100) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $Label_DiskStart = GUICtrlCreateLabel("Disk #", 10, 20, 50, 17) ;Disk Start Label GUICtrlSetState(-1, $GUI_SHOW) ;Label $Input_DiskStart = GUICtrlCreateInput("", 60, 17, 65, 21, $ES_NUMBER) ;DiskStart Input / Numbers Only GUICtrlSetState(-1, $GUI_SHOW) ;Label $Button_Execute1 = GUICtrlCreateButton("Execute", 10, 60, 50, 25) ;Execute Button on left GUICtrlSetOnEvent(-1, "_Button1") ;Execute button calls the _Button function $Button_Close = GUICtrlCreateButton("Exit", 100, 60, 50, 25) ;Close Button GUICtrlSetOnEvent(-1, "_Exit") ;Close button calls _Exit function GUISetState() While 1 WEnd Func _Button1() Const $wbemFlagReturnImmediately = 0x10 Const $wbemFlagForwardOnly = 0x20 Local $oWMI, $oDrives, $sID, $sName, $iSizeinBytes, $Output $oWMI = ObjGet("winmgmts:\\.\root\cimv2") If IsObj($oWMI) Then $oDrives = $oWMI.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($oDrives) Then For $sDrive In $oDrives If $sDrive.Index = GUICtrlRead($Input_DiskStart) Then $sID = $sDrive.DeviceID $sName = $sDrive.Caption $iSizeinBytes = $sDrive.Size $sIndex = $sDrive.Index ConsoleWriteLine("ID: " & $sID & @CRLF & "Drive Index: " & $sIndex & @CRLF & "Drive Name: " & $sName & @CRLF & "Drive Size in Bytes: " & $iSizeinBytes & @CRLF) EndIf Next Else ConsoleWriteLine("Unable to pull Disk Info" & @CRLF) EndIf Else ConsoleWriteLine("Unable to connect to WMI" & @CRLF) EndIf EndFunc Func consolewriteline($text) ConsoleWrite($text & @CRLF) MsgBox(64,"",$text & @CRLF) EndFunc ;==>consolewriteline Func _Exit() ;Exits Application Exit EndFunc ;==>_Exit
  7. Thanks JLogan3o13 for the reply. I do understand that simple math will get me that value. Maybe I wasn't clear enough in my original post. How can I extract the number 4194174 or 4095.88 when only providing the disk number to my interface? Scenario, a person enters the Disk number into an input field. I want to get the results of the disk 2, in this case the returned value could be 4194174 or if there is a way I can read from the disk management "Disk 2" section take the 4095.88 value, then I can do the math in the background to retain my results. Any ideas where I can find either one of these stored values, and how to extract them?
  8. Sorry about that. I realized I didn't attach it after I posted. It's there now on the original post.
  9. How can I get the "Simple Volume Size in MB" for and Disk # I select. The value I am talking about is seen when you open Disk Management, select your disk, right-click > "New Simple Volume...". I would like to enter the desired disk number via an input box. Then return this "Simple Volume Size in MB" value. I don't want the DISKPART size as that is rounded (see picture). I already have script that extracts that, but I found out I need even more precise values. Any ideas of how to get this information? Been reading up on _WinAPI_GetDiskFreeSpaceEx() and _WinAPI_GetDriveNumber(), but I am not seeing how I could use these to get my results. One thing to note is these drives won't have drive letters associated with them at any point, so drive letter searching is useless.
  10. Thanks mikell, this worked wonderfully and was exactly what I was looking for.
  11. Hey guys, what would be the best way to extract/read the following value from a diskpart, list disk, text file. I have a gui that the person specifies the disk number they want to use. Problem is, I need to extract the "Free" space value based off their Disk Input. Any ideas of the best way to do this? Here is what I am exporting to a basic text file right now. If the user inputs the number 3 on my input box, I want to read the file and pull back the value 7167. If they entered 2 I want to pull back 4095. I have looked at things like StringRegExp and _StringExplode, but not sure or very experienced in that, or even sure if that is what I should be doing for this scenario. Any ideas, input, or examples would be greatly appreciated. Disk ### Status Size Free Dyn Gpt -------- ------------- ------- ------- --- --- Disk 0 Online 60 GB 1024 KB Disk 1 Online 100 GB 10 GB Disk 2 Online 4096 GB 4095 GB * Disk 3 Online 7168 GB 7167 GB *
  12. Hi everyone, Let me first start off by saying I love the many things people have posted and created. I have found many useful things to apply this to at my current job. I usually can find examples and tailor them to my specific needs, but this time I am a little stumped. My coding isn't the greatest and like I said, I can usually find what I need in the help or forums. But this time I am stumped. Scenario: I have been tasked to search and extract specific data from our ini files. My problem I run into is doing a global search across all of ini's and extracting the defined data. The key value I am searching on within each ini file is "HTTPServer". Can someone help me in performing the mass search/extract part. So far my script will extract the information I need, but it requires me to specify the ini name within the .au3 file. Like I said before, I would like to search the directory for all ini's named "drsys*.ini" and spit out all results I will attach 2 test.ini files that have been stripped down for simplicity sake that the code will look at. Any help would be greatly appreciated. #include <Array.au3> #include <MsgBoxConstants.au3> ;~ Location of specific ini. ;~ **********NOTE: This is a temp location, need it to search for drsys*.ini and extract from all ini within directory defined $sFile = @DesktopDir & "\drsys0001.ini" ;~ Search the ini for section name containing "HTTPServer" $sSearch = "HttpServer" ; Get section name from ini $aSections = IniReadSectionNames($sFile) ; Clear the result variable $sResult = "" ; Loop through the section names gathering the results For $i = 1 To $aSections[0] ; if we find the search variable in the section name If StringInStr($aSections[$i], $sSearch) Then ; We get the key/value pairing $aKey = IniReadSection($sFile, $aSections[$i]) ; And add them to the result $sResult &= $aKey[1][0] & "=" & $aKey[1][1] & @CRLF EndIf Next ; Results from ini MsgBox(0, "Result for " & $sSearch, $sResult) drsys0001.INI drsys0002.INI
  13. Thank you very much BrewManNH. I knew I was missing something simple like that. It is working now.
  14. I have some input boxes where the starting value ($InputFirst) needs to be greater then or equal to the end value ($InputLast). Problem I am encountering is if the starting value is a single digit number, say 2, and the ending value is any double digit number but the first number of the double digit is less then the first input box (12), I get an error for ($InputFirst) >= ($InputLast) statement. It's like it's treating the first digit as its comparison value and not the whole digit for the ($InputLast) value. Any ideas? Let me know if this even makes sense. I included my if statements I have for checking. If I need to provide more just let me know. ElseIf GUICtrlRead($InputFirst) = "" Then MsgBox($MB_SYSTEMMODAL, "", "No Values.") ElseIf GUICtrlRead($InputFirst) >= GUICtrlRead($InputLast) Then MsgBox($MB_SYSTEMMODAL, "", "Start is greater then End.") ElseIf GUICtrlRead($InputFirst) = 1 Then MsgBox($MB_SYSTEMMODAL, "", "Start needs to be < 1")
×
×
  • Create New...