Jump to content

Casey

Active Members
  • Posts

    59
  • Joined

  • Last visited

Profile Information

  • Location
    USA

Casey's Achievements

Wayfarer

Wayfarer (2/7)

0

Reputation

  1. Yes, the hard coded path reading the encoding was it. Sorry, to have wasted your time.
  2. And then the light came on. Your note caused me to see my immediate failing. A hard coded path from initial testing. Grrr. I will test and return results in a couple of minutes. Humbled.
  3. Because I was having problems reading anything, I downloaded the current stable and beta from the site today and re-installed. My testing has been on current stable. As far as posting an example file, that's a broad ask in that I could post any file. I've got one directory I can read files one one system and the same directory on another system returns all -1. On the same system that could read the directory, if I try another directory, I get all -1. In my understanding, or expectation if you will, I should be able to select any folder on a Windows system provided I have read rights and this would return me an array of encodings for file in the folder. If you test 10 folders across your system and find that they all work; Say some from program files, some folder hanging off root, then you're lucky. I cannot. With such a broad range of failures, I am left thinking that something is left out during execution. Like, the FileGetEncoding code isn't available each time it is run from the editor and isn't making its way into the compiled executable even though I select include all UDFs. I've tried this on SVR 2008R2, Win8.1, Win7 with the same results. I will change the == to see if that is creating a side effect. Thanks for the feedback. Worth a try.
  4. Hello, I'm stuck, again. I'm not grasping why FileGetEncoding works on one folders contents and not others. Why it works partly on one system (The best I've seen) and on other systems it fails on any file. Likely I've made a mistake and probably I'm lucky it is working at all. I have a problem in that the only way I can search for a file is to identify it by its file name because people have named the file differently on many systems and they have even tampered with the file extension. So I thought to see if it had any unique file encoding value that set itself apart from the rest of the files in the folder. As luck would have it, that has turned out to be the case; well, it looks that way because on the couple of systems that this works on, it is returned as 2048 and the other files are a mix of other encoding options. I just don't know where to go from here since the results are hit an miss and I have about 400 systems I need to do a software upgrade on. That upgrade requires me to backup and restore configuration files that are important to registers working. Here is what I have so far, nothing fancy. Any insight would be appreciated. I struggle to read behind the lines so I may not have inferred something from the help file correctly. #RequireAdmin #include <Array.au3> #include <MsgBoxConstants.au3> ;Local $aArray_Base[1][2] = [["File Name","Encoding"]] Local $aArray_Base[0][2] ;_ArrayDisplay($aArray_Base, "2D - Base array") ; Change working directory and FileSelectFolder doesn't change working directory on its own or leave it set if it does FileChangeDir ( FileSelectFolder ( "Select Folder", "C:\" )) ; Define a variable to hold a search "handle" as we loop through the files in a directory $FileSearch = FileFindFirstFile(@WorkingDir & "\*.*") ; Check if the search was successful If $FileSearch = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf ;A while loop where we identify each file in the directory, then read and get its file encoding, and then push the file name and encodinng into an arry While 1 $AFile = FileFindNextFile($FileSearch) If @error Then ExitLoop ;Exclude some known directory names that should not be terminal file names If $AFile == "backup" Or $AFile == "log" Or $AFile == "OUT" Or $AFile == "TR" Then Else ;Get encoding of file $AFile_Encoding = FileGetEncoding ( "C:\CRS\" & $AFile) ;Pass file and and encoding $result to a variable $sFill = $AFile & '|' & $AFile_Encoding ;Use that variable to add data to the array _ArrayAdd($aArray_Base, $sFill) EndIf WEnd ; Close the search handle FileClose($FileSearch) ; Display the results to see what was found. _ArrayDisplay($aArray_Base, "2D - Base array") ; On a few systems this will return an array with file encodings ; On many systems this will return a list of file names but encoding is all -1 ; I do not understand encoding enough to understand why the latter happens ; The systems where this works the most have AutoIt installed so I don't ; Know if that has any bearing. Even on those systems it only works on ; a handful of folders, not all. Why would that be? ; Antivirus is disabled and it was compiled as an admin and run as an admin.
  5. Oh, you on it! I had to add another bit of logic after it failed out on the third RegEx. Added a fourth replacing the + with a ? to catch "C:\S\". I'll update my code in a minute. Now just need to tweak the logic to get rows 8-10 and I'll be done. Thanks a million for catching that. Casey
  6. JCHD, Thank you and I am very sorry. Like I said I was getting cross eyed and the string that I'm stuck on is "C:\S\" and not "C:\S\*". My RegEx actually works on that one. The problem is that it also works on the other using tester. I'll also say that though it is going to take me a bit to read through your version, it looks a bit more intelligent and I think I'll be able to learn something from it. I spotted an error in trimming a string so I have updated my code above and I also see more problems down the line which is fine and why I am working through this exercise. Casey
  7. Hello, I'm back to working on my RegEx skills and trying to come up with something to reformat file directory / file paths that are coming from other applications so that I can feed the resulting list into another script that I came up with. My problem is that I have been testing my RegEx by using https://regex101.com/ with PCRE(PHP). To date it has worked well for me, however, I have hit a stumbling block. In the example below the RegEx on line 158 when applied to pattern "C:\S\*" should pass through the ELSE on line 162 and then get trapped by line 175. Instead, it flows to 159 and then 188. I'm going cross-eyed and I can't spot the problem in the RegEx, If you have a moment and have experience with this kind of thing, would you please take a quick look and tell me what you think is wrong besides this being probably the ugliest way to go about a simple task. The task is simply end up with either a full file path or a directory without a trailing backslash. Thanks in advance, Casey EDIT - [RESOLVED] Replaced script block with corrections, though I am not at all happy with how sloppy it is and I am going to rewrite after learning quite a bit in the process. I just didn't want to leave a truly broken bit out here on the site. #include <Array.au3> #include <Constants.au3> #include <MsgBoxConstants.au3> ; Where we have a full path to a file including file extension Local $aArray[1] = ["C:\S\File.txt"] _ArrayAdd($aArray, "C:\S\Some File.txt") _ArrayAdd($aArray, "C:\Windows\winsxs\FileMaps\program_files_business_objects_common_3.5_bin_d4f3c306b49748a7.cdf-ms") _ArrayAdd($aArray, "C:\S\0_Some File.cdf-ms") ; Where the training backslash is missing from a directory - This is good, DirGetSize format _ArrayAdd($aArray, "C:\S") ; Where the training backslash exists on a directory - This is bad, DirGetSize won't work _ArrayAdd($aArray, "C:\S\") ; Where the path ends in an * - This is bad, DirGetSize value less than C:\S _ArrayAdd($aArray, "C:\S\*") ; Where the path ends in an *.* - This is real bad, DirGetSize won't work and attrib is a laundry list _ArrayAdd($aArray, "C:\S\*.*") _ArrayAdd($aArray, "C:\Program Files (x86)\No Problem\*.*") _ArrayAdd($aArray, "C:\Program Files (x86)\No Problem\*.txt") _ArrayAdd($aArray, "C:\Program Files (x86)\No Problem\a.txt") _ArrayAdd($aArray, "C:\Users\A.Problem") _ArrayAdd($aArray, "C:\Users\A.Problem") ;======================================================================================================================================== ; A must as we are working with Winternal's Process Monitor Output and Handles.exe Output Local $bArray = _ArrayUnique($aArray) _ArrayColInsert($bArray, 1) _ArrayColInsert($bArray, 2) _ArrayDisplay($bArray, "Array @ Beginning") ;======================================================================================================================================== $Cnt = 0 For $i = 0 To UBound($bArray) - 1 $Cnt = $Cnt + 1 Next $Cnt = $Cnt - 1 For $i = 1 To $Cnt Local $LenRegEx = 0 Local $LenArrayItem = 0 ;Test for something that might look like a file extension, greedy, but length of file extension and composition is unknown ;Example: C:\Windows\winsxs\FileMaps\program_files_business_objects_common_3.5_bin_d4f3c306b49748a7.cdf-ms Global $cArray = StringRegExp($bArray[$i][0], "^\w:\\[\. \( \) \w \\ \-]+\\[\w \\ \.-]+", 2) If @error <> 0 Then ;_MsgBox("FIRST REGEX FAILED AND SET ERROR" & @CRLF & @CRLF & "$LenRegEx = " & @CRLF & @CRLF & $LenRegEx & @CRLF & @CRLF & "$LenArrayItem = " & @CRLF & @CRLF & $LenArrayItem) $cArray = StringRegExp($bArray[$i][0], "^\w:\\[\. \(\)\w\\\-]+\\[^\w \\ -]+", 2) If @error <> 0 Then Local $LenRegEx = 0 Local $LenArrayItem = StringLen($bArray[$i][0]) ;_MsgBox("SECOND REGEX FAILED AND SET ERROR" & @CRLF & @CRLF & "$LenRegEx = " & @CRLF & @CRLF & $LenRegEx & @CRLF & @CRLF & "$LenArrayItem = " & @CRLF & @CRLF & $LenArrayItem) $bArray[$i][2] = @ScriptLineNumber Else Local $LenRegEx = StringLen($cArray[0]) Local $LenArrayItem = StringLen($bArray[$i][0]) ;_MsgBox("$LenRegEx = " & @CRLF & @CRLF & $LenRegEx & @CRLF & @CRLF & "$LenArrayItem = " & @CRLF & @CRLF & $LenArrayItem) $bArray[$i][2] = @ScriptLineNumber EndIf Else Local $LenRegEx = StringLen($cArray[0]) Local $LenArrayItem = StringLen($bArray[$i][0]) ;_MsgBox("$LenRegEx = " & @CRLF & @CRLF & $LenRegEx & @CRLF & @CRLF & "$LenArrayItem = " & @CRLF & @CRLF & $LenArrayItem) $bArray[$i][2] = @ScriptLineNumber EndIf If $LenRegEx == $LenArrayItem Then ;_MsgBox("Some are FileGetSize and DirGetSize Compatible " & @CRLF & @CRLF & $bArray[$i][0] & @CRLF & @CRLF & $cArray[0]) $bArray[$i][2] = @ScriptLineNumber $IsThereAnAsterixOrSlash = StringMid($bArray[$i][0], $LenArrayItem, 1) ;_MsgBox("$IsThereAnAsterixOrSlash = " & $IsThereAnAsterixOrSlash) $bArray[$i][2] = @ScriptLineNumber Select Case $IsThereAnAsterixOrSlash = "*" If StringMid($bArray[$i][0], ($LenArrayItem - 1), 2) = "\*" Then ;_MsgBox("A \* existed " & StringLen($bArray[$i][0])) $bArray[$i][2] = @ScriptLineNumber $bArray[$i][1] = StringTrimRight($bArray[$i][0], 2) ;_ArrayDisplay($bArray, @ScriptLineNumber) Else $IsItAsterixDotAsterix = StringMid($bArray[$i][0], $LenArrayItem - 3, 4) ;_MsgBox("$IsItAsterixDotAsterix: " & $IsItAsterixDotAsterix) $bArray[$i][2] = @ScriptLineNumber If $IsItAsterixDotAsterix = "\*.*" Then ;_MsgBox("\*.* " & @CRLF & @CRLF & $IsItAsterixDotAsterix) ;_MsgBox("StringLen($bArray[$i][0] " & @CRLF & @CRLF & StringLen($bArray[$i][0]) & @CRLF & @CRLF & "StringLen($bArray[$i][0] - 4 " & @CRLF & @CRLF & StringLen($bArray[$i][0]) - 4) $bArray[$i][1] = StringTrimRight($bArray[$i][0], StringLen($bArray[$i][0]) - 4) ;_MsgBox("A * or \ existed " & $bArray[$i][0]) $bArray[$i][2] = @ScriptLineNumber ;_ArrayDisplay($bArray, @ScriptLineNumber) ElseIf StringTrimRight($IsItAsterixDotAsterix, 2) = "\*" Then ;_MsgBox("\* " & @CRLF & @CRLF & $IsItAsterixDotAsterix) ;_MsgBox("StringLen($bArray[$i][0] " & @CRLF & @CRLF & StringLen($bArray[$i][0]) & @CRLF & @CRLF & "StringLen($bArray[$i][0] - 4 " & @CRLF & @CRLF & StringLen($bArray[$i][0]) - 2) $bArray[$i][1] = StringTrimRight($bArray[$i][0], StringLen($bArray[$i][0]) - 2) ;_MsgBox("A * or \ existed " & $bArray[$i][0]) $bArray[$i][2] = @ScriptLineNumber ;_ArrayDisplay($bArray, @ScriptLineNumber) Else ;_MsgBox("We shouldn't be able to see this so what's wrong?: " & @CRLF & @CRLF & $bArray[$i][0]) $bArray[$i][2] = @ScriptLineNumber EndIf EndIf Case $IsThereAnAsterixOrSlash = "\" ;_MsgBox("A * or \ existed " & $bArray[$i][0]) $bArray[$i][2] = @ScriptLineNumber $bArray[$i][1] = StringTrimRight($bArray[$i][0], StringLen($bArray[$i][0]) - 1) ;_ArrayDisplay($bArray, @ScriptLineNumber) Case Else ;_MsgBox("We have a good full file path. " & @CRLF & @CRLF & $bArray[$i][0]) $bArray[$i][2] = @ScriptLineNumber $bArray[$i][1] = $bArray[$i][0] ;_ArrayDisplay($bArray, @ScriptLineNumber) EndSelect Else ;=========================================================================================================================== ;Check if no possible file extension by looking if returned regex length equals array element string length ;_MsgBox("$LenRegEx = " & @CRLF & @CRLF & $LenRegEx & @CRLF & @CRLF & "$LenArrayItem = " & @CRLF & @CRLF & $LenArrayItem) $bArray[$i][2] = @ScriptLineNumber ; Could be: C:\S\* $dArray = StringRegExp($bArray[$i][0], "^(.+\\\w+)", 2) If @error <> 0 Then ;_MsgBox("SECOND REGEX FAILED AND SET ERROR") $bArray[$i][2] = @ScriptLineNumber EndIf #cs Full String Match On: C:\S C:\S [return matches source, we have a winner and we already like this guy so we will do nothing to him] #ce $LenRegEx = StringLen($dArray[0]) $LenArrayItem = StringLen($bArray[$i][0]) ;_MsgBox("$LenRegEx = " & @CRLF & @CRLF & $LenRegEx & @CRLF & @CRLF & "$LenArrayItem = " & @CRLF & @CRLF & $LenArrayItem) $bArray[$i][2] = @ScriptLineNumber If $LenRegEx == $LenArrayItem Then ;_MsgBox("DIR NO SLASH " & $dArray[0]) $bArray[$i][2] = @ScriptLineNumber $bArray[$i][1] = $bArray[$i][0] ;_ArrayDisplay($bArray, @ScriptLineNumber) Else $eArray = StringRegExp($bArray[$i][0], "^\w:\\[\. \( \) \w \\ \-]+\\[^\w \\ \.-]+", 2) ;$eArray = StringRegExp($bArray[$i][0], "(?x) ^ \w : \\ [\. \(\)\w\\-]+ \\ [^\w\\ \.-]+", 2) [Same results as above] Thank you for the insight JCHD If @error <> 0 Then ;_MsgBox("THIRD REGEX FAILED AND SET ERROR") $bArray[$i][2] = @ScriptLineNumber $eArray = StringRegExp($bArray[$i][0], "^\w:\\[\. \( \) \w \\ \-]+\\[^\w \\ \.-]?", 2) ; C:\S\ If @error <> 0 Then ;_MsgBox("FOURTH REGEX FAILED AND SET ERROR") $bArray[$i][2] = @ScriptLineNumber $eArray = StringRegExp($bArray[$i][0], "^\w:\\[\. \(\)\w\\\-]+\\[^\w \\ -]+", 2) ; C:\S\*.* -FAILING BC LINE 136 "^(.+\\\w+)" HAS PARTIAL MATCH If @error <> 0 Then ;_MsgBox("FIFTH REGEX FAILED AND SET ERROR") $bArray[$i][2] = @ScriptLineNumber Local $LenRegEx = 0 Local $LenArrayItem = StringLen($bArray[$i][0]) ;_MsgBox("INSANE ->" & $bArray[$i][0] & "<-") $bArray[$i][2] = @ScriptLineNumber Else Local $LenRegEx = StringLen($eArray[0]) Local $LenArrayItem = StringLen($bArray[$i][0]) ;_MsgBox($eArray[0] & @CRLF & @CRLF & $LenRegEx) $bArray[$i][2] = @ScriptLineNumber ;_ArrayDisplay($bArray, @ScriptLineNumber) EndIf Else Local $LenRegEx = StringLen($eArray[0]) Local $LenArrayItem = StringLen($bArray[$i][0]) ;_MsgBox($eArray[0] & @CRLF & @CRLF & $LenRegEx) $bArray[$i][2] = @ScriptLineNumber ;_ArrayDisplay($bArray, @ScriptLineNumber) EndIf Else Local $LenRegEx = StringLen($eArray[0]) Local $LenArrayItem = StringLen($bArray[$i][0]) ;_MsgBox($eArray[0] & @CRLF & @CRLF & $LenRegEx) $bArray[$i][2] = @ScriptLineNumber ;_ArrayDisplay($bArray, @ScriptLineNumber) If $LenRegEx = $LenArrayItem Then $bArray[$i][1] = $bArray[$i][0] $bArray[$i][2] = @ScriptLineNumber ;_MsgBox("$LenRegEx = " & @CRLF & @CRLF & $LenRegEx & @CRLF & @CRLF & "$LenArrayItem = " & @CRLF & @CRLF & $LenArrayItem) ;_ArrayDisplay($bArray, @ScriptLineNumber) EndIf EndIf $fArray = StringRegExp($bArray[$i][0], "^\w\:\\[\. \(\)\w\\\-]+\\[^\w \\ -]+", 2) If @error <> 0 Then $bArray[$i][2] = @ScriptLineNumber ;_ArrayDisplay($bArray, @ScriptLineNumber) Else Local $LenRegEx = StringLen($fArray[0]) Local $LenArrayItem = StringLen($bArray[$i][0]) ;_MsgBox($fArray[0] & @CRLF & @CRLF & $LenRegEx) $bArray[$i][2] = @ScriptLineNumber ;_ArrayDisplay($bArray, @ScriptLineNumber) If $LenRegEx = $LenArrayItem Then $bArray[$i][1] = StringTrimRight($bArray[$i][0], 4) ;$bArray[$i][1] = $bArray[$i][0] $bArray[$i][2] = @ScriptLineNumber ;_MsgBox("$LenRegEx = " & @CRLF & @CRLF & $LenRegEx & @CRLF & @CRLF & "$LenArrayItem = " & @CRLF & @CRLF & $LenArrayItem) $LenRegEx = 0 ;_ArrayDisplay($bArray, @ScriptLineNumber) Else $gArray = StringRegExp($bArray[$i][0], "^\w\:\\[\. \(\)\w\\\-]+\\[^ \\ -]+", 2) If @error <> 0 Then $bArray[$i][2] = @ScriptLineNumber ;_ArrayDisplay($bArray, @ScriptLineNumber) Else Local $LenRegEx = StringLen($gArray[0]) Local $LenArrayItem = StringLen($bArray[$i][0]) ;_MsgBox("$LenRegEx = " & @CRLF & @CRLF & $LenRegEx & @CRLF & @CRLF & "$LenArrayItem = " & @CRLF & @CRLF & $LenArrayItem) If $LenRegEx = $LenArrayItem Then $bArray[$i][1] = StringTrimRight($bArray[$i][0], 6) ;$bArray[$i][1] = $bArray[$i][0] $bArray[$i][2] = @ScriptLineNumber ;_MsgBox("$LenRegEx = " & @CRLF & @CRLF & $LenRegEx & @CRLF & @CRLF & "$LenArrayItem = " & @CRLF & @CRLF & $LenArrayItem) ;_ArrayDisplay($bArray, @ScriptLineNumber) EndIf EndIf EndIf EndIf $IsThereAnAsterixOrSlash = StringMid($bArray[$i][0], $LenArrayItem, 1) ;_MsgBox($bArray[$i][0] & @CRLF & @CRLF & "->" & $IsThereAnAsterixOrSlash & "<-") $bArray[$i][2] = @ScriptLineNumber Select Case $LenRegEx == $LenArrayItem #cs Full String Match On: C:\S\ C:\S\* #ce If $IsThereAnAsterixOrSlash = "*" Then $bArray[$i][1] = StringTrimRight($bArray[$i][0], 2) ;_MsgBox("An * existed " & $bArray[$i][0]) $bArray[$i][2] = @ScriptLineNumber ;_ArrayDisplay($bArray, @ScriptLineNumber) EndIf If $IsThereAnAsterixOrSlash = "\" Then $bArray[$i][1] = StringTrimRight($bArray[$i][0], 1) ;_MsgBox("A \ existed " & $bArray[$i][0]) $bArray[$i][2] = @ScriptLineNumber ;_ArrayDisplay($bArray, @ScriptLineNumber) Else ;_MsgBox("OUCH Who Knows") $bArray[$i][2] = @ScriptLineNumber EndIf Case Else ;_MsgBox("We shouldn't be able to see this so what's wrong?: " & @CRLF & @CRLF & $bArray[$i][0]) $bArray[$i][2] = @ScriptLineNumber EndSelect EndIf EndIf ;=========================================================================================================================== Next $bArray[0][0] = "*** Source Format of Text ***" $bArray[0][1] = "*** Reformatted Text ***" $bArray[0][2] = "*** Script Line Exited ***" _ArrayDisplay($bArray, "Array @ End") ; #FUNCTION# ==================================================================================================================== ; CUSTOM MSGBOX - ADDS SCRIPT LINE NUMBER AS TITLE FOR DEBUGGING - ADD MSGBOXES TO SOURCE IF NEEDED ; EXAMPLE MSGBOX ;_MsgBox("The value for $stringinput is not as expected == " & $stringinput) Func _MsgBox($sText, $sTitle = @ScriptLineNumber) MsgBox(0, "-" & $sTitle & "-", $sText) EndFunc ;==>_MsgBox ; ===============================================================================================================================
  8. The problem with not knowing the answer is not knowing the correct question to ask to find the answer. This is the exact predicament that I find myself at this moment so I will do my best to put order to some abstract thoughts. Given the function ControlGetHandle by definition retrieves the internal handle of a control. Let’s assume for the sake of argument that I have turned off UAC on both my test system and my problem system and that both systems are Windows 7 x86.That regardless of whether I have #RequireAdmin at the beginning of my script, that the results are the same on my test system. That the lines of code that I am having difficulty with are as follows $d = 0 Do $TestX = ControlFocus("Pxl", "Database has expired for", "Button1") $TestXa = ControlGetHandle("Pxl", "Database has expired for", "Button1") If $TestXa <> 0 Then ControlClick("Pxl", "Database has expired for", "Button1") Sleep(2000) EndIf $d = $d + 1 Until $d = 7What I am seeing happen is that on a test system, this works and I am able to interact with this button. However, if I take this same code to another system that has this client software installed, I cannot. I checked to see what was going on by doing the following: $Hope=WinExists("Pxl", "Database has expired for") MsgBox(0,"","If equals one window can be seen = " & $Hope) MsgBox(0,"",WinGetText("Pxl", "Database has expired for"))The result was a zero with no text being returned on the problem system. I then had the client software uninstalled and reinstalled making sure that elevated permissions were used. Following the reinstall, WinExists returned a 1, the text was returned, and the automation was successful. Sunshine, puppies and unicorns all day long. Two days later, on this same system, WinExists went back to being a zero for some unexplained reason. After doing an uninstall / reinstall routine again, WinExists still returns a zero. The fairy tale ended. Part of me wants to believe that it is an issue with the client installer but the other part fails to understand why it would just stop working or why on another system of the same OS persuasion, it runs flawlessly for 5,000 executions. To take this a step farther, if I run the Client software on the problem system as an administrator, WinExists returns a 1. So what would make a control that was previously available to a standard user session suddenly only want to give up its information when run as administrator? Why would one install work for 2 days and then break? Then have another install not work? So if I am making sense to this point, I have to ask, what I am missing? I have a reliable test where neither the script nor the client application need to be run as administrator yet I have this problem on other systems. Are there other factors that would create this behavior in AutoIt other than UAC? If I wanted to search the internet to find articles on how AutoIt retrieves the handles or better yet how the handles are exposed to the user session, what would I really search for? I have looked at process explorer and I see an access column if I turn on handles but it is my understanding that this is the access that was requested at the time the handle was created and is aimed at what the control is allowed to do but not who can access the information of the control. I am guessing that this possibility of access to the handle exists as it is the only conclusion that fits with what I am seeing, or am I wrong? This last question is what drove me to ask this question in the forum as I am having no success in understanding the concept of how this happens or what to search for. Any ideas? As a side note, here is what the info tool exposes about the button: >>>> Window <<<< Title: Pxl Class: #32770 Position: 477, 412 Size: 326, 161 Style: 0x94C801C5 ExStyle: 0x00010101 Handle: 0x00200880 >>>> Control <<<< Class: Button Instance: 1 ClassnameNN: Button1 Name: Advanced (Class): [CLASS:Button; INSTANCE:1] ID: 2 Text: OK Position: 226, 96 Size: 88, 26 ControlClick Coords: 22, 14 Style: 0x50030000 ExStyle: 0x00000004 Handle: 0x00130752 >>>> Mouse <<<< Position: 728, 547 Cursor ID: 0 Color: 0xDBDBDB >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< OK Database has expired for >>>> Hidden Text <<<< P.S. Thank you Jon for getting my access restored. V/r Casey
  9. Thank you both for your replies. I adjusted the code for error checking. I really should have remembered the blocking. I have been away from this for a while, but no excuse. Thanks again. Casey
  10. So, I have been poking around to see if there was an easy way to use forfiles.exe in one of my script to get a total of the space used by different file types in a share. I present 2 examples. The first gives the wrong total size. It gives only the size of the first file encountered. The second example works and gives the correct total. The command is to return the size of files in C:TempTest that are PDFs. Works on Win7x64. So, why is it that the MsgBox causes this. I know I am forgetting something. Any ideas? #include <Constants.au3> #include <Array.au3> $n = 0 $strCmdOutput = Run(@ComSpec & " /c " & 'C:\Windows\System32\forfiles.exe' & " /P C:\Temp\Test /S /M *.pdf /C " & '"cmd /c echo @fsize" ', "C:\Temp\Test", @SW_HIDE, 0x2) While 1 $strSTDOUT = StdoutRead($strCmdOutput) If $strSTDOUT <> "" Then MsgBox(0."This doesn't work. The end result is the same size as the first identified file", $strSTDOUT) $n = $n + $strSTDOUT EndIf If @error Then ExitLoop WEnd MsgBox(0, "File size total for all PDFs in the C:\Temp\Test direcotry", $n) #include <Constants.au3> #include <Array.au3> $n = 0 $strCmdOutput = Run(@ComSpec & " /c " & 'C:\Windows\System32\forfiles.exe' & " /P C:\Temp\Test /S /M *.pdf /C " & '"cmd /c echo @fsize" ', "C:\Temp\Test", @SW_HIDE, 0x2) While 1 $strSTDOUT = StdoutRead($strCmdOutput) If $strSTDOUT <> "" Then $n = $n + $strSTDOUT EndIf If @error Then ExitLoop WEnd MsgBox(0, "File size total for all PDFs in the C:\Temp\Test direcotry", $n) Thanks, Casey
  11. BrewManNH, That is a thought and if I follow that path I will have to change some other things to make it work. I thought that I had read that it was possible to do both and except for that odd behavior, it seems possible. Thanks for the advice. I will start altering it an see how that works. AdmiralAlkex Removing the loop doesn't change the behavior. Also, I am assuming that when the gui is deleted that even if it were in the loop, that would go away. Or am I mistaken? Either way, there is something else happening at the point that the on event should fire that causes it not to the second time _gui2 is called. Thanks again both of you. V/r Casey
  12. Hello All, We have a small script designed to log what we are up. The script as it was originally written used tray items to make specific type entries whenever the person wanted to make a log entry. It also used an AdlibRegister function to trigger a reminder message box every 15 minutes. All was good until I decided to replace the reminder message box with a gui that could allow the user to select the type rather than closing it and selecting a tray item. I learned quickly that the tray items wouldn't do anything when they were selected after the gui was closed. So I am attempting a rewrite to make this possible. The code below has quite a bit incomplete and some stuff I need to trim out or change. However, I am coming to you with my current issue. Instead of waiting the 15 minute intervals the AdlibRegister function is set to, I temporarily set the "about" tray item to call the function that I am testing. Logically speaking: _gui1 is called when opening the scriptWhen _gui2 is called either from the about tray item or the AdlibRegister function the combo is populatedWhen the user selects an item from the combo, GUIOnEventMode 1 is used to detect the selectionWhen the detection is made, the _ItemSelect function is calledThe selection type value is retrievedThe gui is deletedAn input box appears to make the log entryThen I destroy the tray items because I can't figure out how to get them to do anything if I don'tI then call tray items to be created againThe loop: _gui1 -> _gui2 -> _ItemSelect -> _gui1 In the end, I should have created a means of switching reading messages between the tray and the gui. This has resulted in almost exactly that. However, after _gui2 appears the second time, the GUICtrlSetOnEvent doesn't work anymore. Any suggestions as to why this is would be greatly appreciated. V/r Casey #NoTrayIcon #include <GUIConstantsEx.au3> #include <GuiComboBox.au3> #include <Constants.au3> #include <GuiComboBoxEx.au3> If Not FileExists(@MyDocumentsDir & "\ActivityLogs\") Then DirCreate(@MyDocumentsDir & "\ActivityLogs") EndIf AdlibRegister("_CheckTime", 500) Opt("GUIOnEventMode", 1) Global $hGUI2 = 9999, $Sel, $Item, $entryData2 _gui1() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _gui1() Global $entryitem, $phoneitem, $ngbitem, $genericitem, $openlogitem, $aboutitem, $exititem Opt("TrayMenuMode", 3) ; Default tray menu items (Script Paused/Exit) will not be shown. $entryitem = TrayCreateItem("New task...") $phoneitem = TrayCreateItem("New phone call...") $ngbitem = TrayCreateItem("New NGB item...") $genericitem = TrayCreateItem("New generic entry..") TrayCreateItem("") $openlogitem = TrayCreateItem("Open task log") TrayCreateItem("") $aboutitem = TrayCreateItem("About") $exititem = TrayCreateItem("Exit") TraySetState() _LogOpenClose("LAUNCH") While 1 $msg = TrayGetMsg() Select Case $msg = $aboutitem ;MsgBox(64, "About", "ABOUT ENOUGH TO DRIVE ME CRAZY.") _gui2() Case $msg = $entryitem _WriteLog("TASK") Case $msg = $phoneitem _WriteLog("PHONE") Case $msg = $ngbitem _WriteLog("NGB") Case $msg = $genericitem _WriteLog("MISC") Case $msg = $openlogitem _OpenLog() Case $msg = $exititem ExitLoop EndSelect WEnd EndFunc ;==>_gui1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _gui2() Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $hGUI2 = GUICreate("Update Your Progress", 260, 70) ; will create a dialog box that when displayed is centered GUICtrlCreateLabel("Update your calendar for " & @HOUR & ":" & @MIN, 10, 10, 200) $Item = GUICtrlCreateCombo("TASK", 10, 30) ; create first item ;MsgBox(0,"$Item",$Item) GUICtrlSetData($Item, "PHONE|NGB|MISC", "TASK") ; add other item snd set a new default _GUICtrlComboBoxEx_ShowDropDown($Item, True) $ItemCheck = GUICtrlSetOnEvent($Item, "_ItemSelect") ;MsgBox(0,"$ItemCheck",$ItemCheck) GUISetState() While 1 Sleep(100) WEnd EndFunc ;==>_gui2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _ItemSelect() MsgBox(0, "", "_ItemSelect() Entered") $Sel = _GUICtrlComboBox_GetCurSel($Item) GUIDelete($hGUI2) ;Note: at this point @GUI_CTRLID would equal $Item position in the array Select Case $Sel = "0" $boxTitle = "Add a task to log." $boxPrompt = "Enter a task to be added to the task log:" $boxDefault = "@" & @HOUR & ":" & @MIN & " - " $type = "TASK" ;Give a name to the array position Case $Sel = "1" $boxTitle = "Add a phone call to log." $boxPrompt = "Enter a phone call to be added to the task log:" & @CRLF & @CRLF & "@Time - Caller, #, Subject" $boxDefault = "@" & @HOUR & ":" & @MIN & " - " $type = "PHONE" Case $Sel = "2" $boxTitle = "Add an NGB related item to log." $boxPrompt = "Enter an NGB-related item to be added to the task log:" & @CRLF & @CRLF & "@Time - Who, What" $boxDefault = "@" & @HOUR & ":" & @MIN & " - " $type = "NGB" Case Else $boxTitle = "Generic Entry" $boxPrompt = "Enter text to add to the log." $boxDefault = "@" & @HOUR & ":" & @MIN & " - " $type = "MISC" EndSelect Sleep(500) $entryData2 = InputBox($boxTitle, $boxPrompt, $boxDefault) If Not $entryData2 = "" Then $logFile = FileOpen(@MyDocumentsDir & "\ActivityLogs\" & @YEAR & @MON & @MDAY & ".log", 1) FileWriteLine($logFile, $type & " - " & $entryData2) FileClose($logFile) EndIf TrayItemDelete($entryitem) TrayItemDelete($phoneitem) TrayItemDelete($ngbitem) TrayItemDelete($genericitem) TrayItemDelete($openlogitem) TrayItemDelete($aboutitem) TrayItemDelete($exititem) TraySetState(2) _gui1() EndFunc ;==>_ItemSelect ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _CheckTime() $iMin = @MIN If @SEC = 0 Then Switch $iMin Case "00" _Notify("00") Sleep(1000) Case "15" _Notify("15") Sleep(1000) Case "30" _Notify("30") Sleep(1000) Case "45" _Notify("45") Sleep(1000) Case Else Sleep(1000) EndSwitch EndIf EndFunc ;==>_CheckTime ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _Notify($varMin) _gui2() ;_LogWindows() EndFunc ;==>_Notify ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _LogWindows() $logFile = FileOpen(@MyDocumentsDir & "\ActivityLogs\" & @YEAR & @MON & @MDAY & ".log", 1) $var = WinList() FileWriteLine($logFile, "=========================================" & @CRLF & "LOG STARTING: " & @YEAR & @MON & @MDAY & " " & @HOUR & ":" & @MIN) FileWriteLine($logFile, "OPEN WINDOWS: ") For $i = 1 To $var[0][0] ; Only display visble windows that have a title If $var[$i][0] <> "" And _IsVisible($var[$i][1]) Then ;MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1]) $strActive = _IsForeground($var[$i][1]) FileWriteLine($logFile, $strActive & $var[$i][0]) EndIf Next FileWriteLine($logFile, @CRLF) FileWriteLine($logFile, "TASKS:") FileClose($logFile) EndFunc ;==>_LogWindows ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _LogOpenClose($action) $logFile = FileOpen(@MyDocumentsDir & "\ActivityLogs\" & @YEAR & @MON & @MDAY & ".log", 1) Switch $action Case "LAUNCH" $status = "PROGRAM LAUNCH" Case "EXIT" $status = "PROGRAM EXIT" EndSwitch FileWriteLine($logFile, "=========================================" & @CRLF & $status & ": " & @YEAR & @MON & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF & "=========================================") FileClose($logFile) EndFunc ;==>_LogOpenClose ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _IsVisible($handle) If BitAND(WinGetState($handle), 2) Then Return 1 Else Return 0 EndIf EndFunc ;==>_IsVisible ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _IsForeground($handle) If BitAND(WinGetState($handle), 8) Then Return "***** " Else Return "" EndIf EndFunc ;==>_IsForeground ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _WriteLog($type) Select Case $type = "NGB" $boxTitle = "Add an NGB related item to log." $boxPrompt = "Enter an NGB-related item to be added to the task log:" & @CRLF & @CRLF & "@Time - Who, What" $boxDefault = "@" & @HOUR & ":" & @MIN & " - " Case $type = "PHONE" $boxTitle = "Add a phone call to log." $boxPrompt = "Enter a phone call to be added to the task log:" & @CRLF & @CRLF & "@Time - Caller, #, Subject" $boxDefault = "@" & @HOUR & ":" & @MIN & " - " Case $type = "TASK" $boxTitle = "Add a task to log." $boxPrompt = "Enter a task to be added to the task log:" $boxDefault = "@" & @HOUR & ":" & @MIN & " - " Case Else $boxTitle = "Generic Entry" $boxPrompt = "Enter text to add to the log." $boxDefault = "@" & @HOUR & ":" & @MIN & " - " EndSelect ;$entryData = InputBox($boxTitle, $boxPrompt, $boxDefault) $entryData = InputBox($boxTitle, $boxPrompt, $boxDefault & Send("{RIGHT}") & Send("{BS 2}")) If Not $entryData = "" Then $logFile = FileOpen(@MyDocumentsDir & "\ActivityLogs\" & @YEAR & @MON & @MDAY & ".log", 1) FileWriteLine($logFile, $type & " - " & $entryData) FileClose($logFile) EndIf EndFunc ;==>_WriteLog ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _OpenLog() ShellExecute(@MyDocumentsDir & "\ActivityLogs\" & @YEAR & @MON & @MDAY & ".log") EndFunc ;==>_OpenLog ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func MessageBox($iIndex) MsgBox("", "MsgBox " & $iIndex, "Test from Gui " & $iIndex) EndFunc ;==>MessageBox
  13. Not sure exactly what your after but here is an example of how to get all the mapped drives for all users with profiles on a computer. Designed for Vista /Win7 using some functions from .AU3 files that can be found on this site. #RequireAdmin #include <./SecurityEx.au3> #include <./Reg.au3> #cs Logic: 1. obtain mapped drives from users hive(s) "RemotePath" values 2. output as shortcut in G6 folder #ce #cs http://www.autoitscript.com/forum/topic/75250-registry-udfs/page__p__545798#entry545798 Reg.au3 - Requires SecurityEx.au3 Current functions: _RegLoadHive _RegRestoreHive _RegSaveHive _RegUnloadHive Notes: All functions are supposed to work on Windows 2000 and later #ce ; ALL USER PROFILES NOT SYSTEM PROFILES - Look for NTUSER.dat, Load it if Found, Create Shortcut in C:G6%username%Mapped_Drives from Registry Entries $UDrive = FileSelectFolder("Select the -> DRIVE LETTER <- containing the User Structure you wish to Scan", "") If @error = 1 Then MsgBox(0, "User Canceled Operation", "You chose to cancel. Closing utility now.") Exit EndIf $Drive = StringLeft($UDrive, 3) $OA = @OSArch Select Case $OA = "X86" $ProfileSearch = FileFindFirstFile($Drive & "Users*.*") ; Check if the search was successful If $ProfileSearch = -1 Then MsgBox(0, "Error", "No files/directories matched the Users directory search pattern. Exiting now.") Exit EndIf While 1 $Profile = FileFindNextFile($ProfileSearch) If @error Then ExitLoop If $Profile == "All Users" Or $Profile == "LocalService" Or $Profile == "NetworkService" Or $Profile == "Administrator" Or $Profile == "Default" Or $Profile == @UserName Then Else $NTUSERDAT = FileFindFirstFile($Drive & "Users" & $Profile & "NTUSER.DAT") If $NTUSERDAT = -1 Then ;Exit EndIf While 1 $DAT = FileFindNextFile($NTUSERDAT) If @error Then ExitLoop If $DAT = "" Then ExitLoop If StringInStr($DAT, 'NTUSER.DAT', 2) Then ;MsgBox(0, "WAHOO", $DAT) ;This .au3 library doesn't use the 64 suffix like the main autoit libraies ;MsgBox(0, "Hive Path", $Drive & "Users" & $Profile & "NTUSER.DAT") _RegLoadHive($Drive & "Users" & $Profile & "NTUSER.DAT", "HKEY_USERSNT") For $i = 1 To 10 Local $var = RegEnumKey("HKUNTNetwork", $i) If @error <> 0 Then ExitLoop For $bi = 1 To 6 Local $bvar = RegEnumVal("HKUNTNetwork" & $var, $bi) If @error <> 0 Then ExitLoop ;MsgBox(4096, "Value Name # " & $bi & " under the Network Subkey", $bvar) If $bvar = "RemotePath" Then If FileExists("C:G6" & $Profile & "Mapped_Drives") Then ;MsgBox(4096, "", "") $Dest = "C:G6" & $Profile & "Mapped_Drives" Else DirCreate("C:G6" & $Profile & "Mapped_Drives") $Dest = "C:G6" & $Profile & "Mapped_Drives" EndIf $Target = RegRead("HKUNTNetwork" & $var, $bvar) ;MsgBox(0, "Creating Shortcut", $Dest & $var & ".lnk") FileCreateShortcut($Target, $Dest & $var & ".lnk", "", "", "", @SystemDir & "shell32.dll", "", "15", @SW_SHOWNORMAL) EndIf Next ;MsgBox(4096, "SubKey #" & $i & " under NTNetwork: ", $var) Next ;This .au3 library doesn't use the 64 suffix like the main autoit libraies _RegUnloadHive("HKEY_USERSNT") EndIf WEnd FileClose($NTUSERDAT) EndIf WEnd ; Close the search handle FileClose($ProfileSearch) Case $OA = "X64" $ProfileSearch = FileFindFirstFile($Drive & "Users*.*") ; Check if the search was successful If $ProfileSearch = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $Profile = FileFindNextFile($ProfileSearch) If @error Then ExitLoop If $Profile == "All Users" Or $Profile == "LocalService" Or $Profile == "NetworkService" Or $Profile == "Administrator" Or $Profile == "Default" Or $Profile == @UserName Then Else $NTUSERDAT = FileFindFirstFile($Drive & "Users" & $Profile & "NTUSER.DAT") If $NTUSERDAT = -1 Then ;Exit EndIf While 1 $DAT = FileFindNextFile($NTUSERDAT) If @error Then ExitLoop If $DAT = "" Then ExitLoop If StringInStr($DAT, 'NTUSER.DAT', 2) Then ;MsgBox(0, "WAHOO", $DAT) ;This .au3 library doesn't use the 64 suffix like the main autoit libraies ;MsgBox(0, "Hive Path", $Drive & "Users" & $Profile & "NTUSER.DAT") _RegLoadHive($Drive & "Users" & $Profile & "NTUSER.DAT", "HKEY_USERSNT") For $i = 1 To 10 Local $var = RegEnumKey("HKU64NTNetwork", $i) If @error <> 0 Then ExitLoop For $bi = 1 To 6 Local $bvar = RegEnumVal("HKU64NTNetwork" & $var, $bi) If @error <> 0 Then ExitLoop ;MsgBox(4096, "Value Name # " & $bi & " under the Network Subkey", $bvar) If $bvar = "RemotePath" Then If FileExists("C:G6" & $Profile & "Mapped_Drives") Then ;MsgBox(4096, "", "") $Dest = "C:G6" & $Profile & "Mapped_Drives" Else DirCreate("C:G6" & $Profile & "Mapped_Drives") $Dest = "C:G6" & $Profile & "Mapped_Drives" EndIf $Target = RegRead("HKU64NTNetwork" & $var, $bvar) ;MsgBox(0, "Creating Shortcut", $Dest & $var & ".lnk") FileCreateShortcut($Target, $Dest & $var & ".lnk", "", "", "", @SystemDir & "shell32.dll", "", "15", @SW_SHOWNORMAL) EndIf Next ;MsgBox(4096, "SubKey #" & $i & " under NTNetwork: ", $var) Next ;This .au3 library doesn't use the 64 suffix like the main autoit libraies _RegUnloadHive("HKEY_USERSNT") EndIf WEnd FileClose($NTUSERDAT) EndIf WEnd ; Close the search handle FileClose($ProfileSearch) Case Else ;Either the architecture was not determined or it was IA64 . Exit (111) EndSelect
  14. Sorry, I am lost as to what you are really asking. Is this of any help? #RequireAdmin #include <GUIConstantsEx.au3> #Include <File.au3> #include <WindowsConstants.au3> Global $FileVersion_1, $FileVersion_1a If Not FileExists( @ScriptDir & "\info.log") Then _FileCreate( @ScriptDir & "\info.log") EndIf $InstallLog = @ScriptDir & "\info.log" GUICreate("Get Info For Scripting", 300, 150) ; will create a dialog box that when displayed is centered $GetFileVer = GUICtrlCreateButton("Get File Version Info", 19, 33, 270, 25) $ViewFileVer=GUICtrlCreateButton("View Results", 19, 90, 270, 25) GUISetState(@SW_SHOW) ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $GetFileVer $FileVersion_1a = "" _GetFile() _FileWriteLog($InstallLog, @CRLF & @CRLF & "The queried computers operating system VERSION was: " & @OSVersion & @CRLF) _FileWriteLog($InstallLog, @CRLF & @CRLF & "The queried computers operating system BUILD was: " & @OSBuild & @CRLF) _FileWriteLog($InstallLog, @CRLF & @CRLF & "The queried computers operating system SERVICEPACK was: " & @OSServicePack & @CRLF) _FileWriteLog($InstallLog, @CRLF & @CRLF & "The queried computers operating system ARCHITECTUE was: " & @OSArch & @CRLF) _FileWriteLog($InstallLog, @CRLF & @CRLF & "The queried computers operating system TYPE was: " & @OSTYPE & @CRLF & "____________________________________________________________________") $FileVersion_1b = FileGetVersion($FileVersion_1a, "Comments") _FileWriteLog($InstallLog, @CRLF & @CRLF & "File version information for " & $FileVersion_1a & @CRLF & @CRLF & " Comments:" & @CRLF & "____________________________________________________________________") $FileVersion_1c = FileGetVersion($FileVersion_1a, "InternalName") _FileWriteLog($InstallLog, "InternalName,: " & $FileVersion_1c & @CRLF & "____________________________________________________________________") $FileVersion_1d = FileGetVersion($FileVersion_1a, "ProductName") _FileWriteLog($InstallLog, "ProductName: " & $FileVersion_1d & @CRLF & "____________________________________________________________________") $FileVersion_1e = FileGetVersion($FileVersion_1a, "CompanyName") _FileWriteLog($InstallLog, "CompanyName: " & $FileVersion_1e & @CRLF & "____________________________________________________________________") $FileVersion_1f = FileGetVersion($FileVersion_1a, "LegalCopyright") _FileWriteLog($InstallLog, "LegalCopyright: " & $FileVersion_1f & @CRLF & "____________________________________________________________________") $FileVersion_1g = FileGetVersion($FileVersion_1a, "ProductVersion") _FileWriteLog($InstallLog, "ProductVersion: " & $FileVersion_1g & @CRLF & "____________________________________________________________________") $FileVersion_1h = FileGetVersion($FileVersion_1a, "FileDescription") _FileWriteLog($InstallLog, "FileDescription: " & $FileVersion_1h & @CRLF & "____________________________________________________________________") $FileVersion_1i = FileGetVersion($FileVersion_1a, "LegalTrademarks") _FileWriteLog($InstallLog, "LegalTrademarks: " & $FileVersion_1i & @CRLF & "____________________________________________________________________") $FileVersion_1j = FileGetVersion($FileVersion_1a, "PrivateBuild") _FileWriteLog($InstallLog, "PrivateBuild: " & $FileVersion_1j & @CRLF & "____________________________________________________________________") $FileVersion_1k = FileGetVersion($FileVersion_1a, "FileVersion") _FileWriteLog($InstallLog, "FileVersion: " & $FileVersion_1k & @CRLF & "____________________________________________________________________") $FileVersion_1l = FileGetVersion($FileVersion_1a, "OriginalFilename") _FileWriteLog($InstallLog, "OriginalFilename: " & $FileVersion_1l & @CRLF & "____________________________________________________________________") $FileVersion_1m = FileGetVersion($FileVersion_1a, "SpecialBuild") _FileWriteLog($InstallLog, "SpecialBuild: " & $FileVersion_1m & @CRLF & "____________________________________________________________________") $FileVersion_1n = FileGetVersion($FileVersion_1a, "CompiledScript") _FileWriteLog($InstallLog, "CompiledScript: " & $FileVersion_1n & @CRLF & "____________________________________________________________________") $FileVersion_1o = FileGetVersion($FileVersion_1a, "DefaultLangCodepage") _FileWriteLog($InstallLog, "DefaultLangCodepage: " & $FileVersion_1o & @CRLF & "____________________________________________________________________") $FileVersion_1p = FileGetVersion($FileVersion_1a) _FileWriteLog($InstallLog, "Argument without additional string name (Version): " & $FileVersion_1p & @CRLF & "____________________________________________________________________") $FileSize_1a = FileGetSize($FileVersion_1a) _FileWriteLog($InstallLog, "File Size: " & $FileSize_1a & @CRLF & "____________________________________________________________________") Case $msg = $ViewFileVer ;Run("notepad.exe " & @ScriptDir & "\00_InfoHarvest.log") Run("C:\Windows\explorer.exe " & $InstallLog, "") Case Else EndSelect WEnd GUIDelete() Func _GetFile() $SearchIt = InputBox("Remote System", "Do you want to explore a remote system") If @error = 1 Or $SearchIt = "" Then $message = "Browse for the file you wish to examine." $FileVersion_1xa = FileOpenDialog($message, @WindowsDir & "\", "All (*.*)", 1 + 4) $FileVersion_1a = $FileVersion_1xa Return $FileVersion_1a EndIf If $SearchIt <> "" Then $message = "Browse for the file you wish to examine." $FileVersion_1xa = FileOpenDialog($message, "\\" & $SearchIt & "\C$\Windows", "All (*.*)", 1 + 4) $FileVersion_1a = $FileVersion_1xa FileClose($FileVersion_1xa) Return $FileVersion_1a EndIf EndFunc ;==>_GetFile
  15. I am a little fuzzy on what you are asking but if the question is how to pull the data from your input boxes and spit something out to CMD here is basically what I think your looking for. It is untested. The second message box shows you what the command would look like. I provided the command syntax commented out. #RequireAdmin #include <ButtonConstants.au3> #include <GuiEdit.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= GUICreate("Driver Add", 298, 228, 495, 227) $GetMountPath = GUICtrlCreateButton("Mount", 19, 33, 62, 25) $GetDriversPath = GUICtrlCreateButton("Drivers", 19, 71, 62, 25) $GetImagePath = GUICtrlCreateButton("Image", 19, 109, 63, 26) $RunProcess2AddDrivers = GUICtrlCreateButton("Add Drivers", 19, 147, 63, 26) $input1 = GUICtrlCreateInput("Mount folder", 91, 33, 173, 20) $input2 = GUICtrlCreateInput("Drivers Folder", 91, 71, 173, 20) $input3 = GUICtrlCreateInput("Image To Add Drivers To", 91, 109, 173, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $GetMountPath button1() Case $msg = $GetDriversPath button2() Case $msg = $GetImagePath button3() Case $msg = $RunProcess2AddDrivers MsgBox(0, "", "Your syntax assumes that you have already mounted the image so why have a select button for it?" & @CRLF & @CRLF & "Unless that is if you are planning on running 2 seperate commands.") $MountPath = GUICtrlRead($input1) $DriverPath = GUICtrlRead($input2) ;prevoius 2 commands serve to save you from your self when you might decide to type something into the boxes $ImagePath = GUICtrlRead($input3) ;previous command not really needed given the syntax that you provided MsgBox(0, "", "Dism /Image:" & $MountPath & " /Add-Driver /Driver:" & $DriverPath & " /Recurse") ; "Dism /Image:C:\winpex86\mount /Add-Driver /Driver:c:\driver /Recurse" ;Run(@ComSpec & " /c Dism " & $MountPath & " /Add-Driver /Driver:" & $DriverPath & " /Recurse", '', @SW_SHOW, 1) ;In the previous command you may need to provide the full path to Dism if it isn't in the PATH variable. Remove the ; at the beginning of the previous ine to see if it works. EndSelect WEnd GUIDelete() Func button1() $Foldername = FileSelectFolder("Select a folder", "") GUICtrlSetData($input1, $Foldername) EndFunc ;==>button1 Func button2() $Foldername = FileSelectFolder("Select a folder", "") GUICtrlSetData($input2, $Foldername) EndFunc ;==>button2 Func button3() $Foldername = FileSelectFolder("Select a folder", "") GUICtrlSetData($input3, $Foldername) EndFunc ;==>button3
×
×
  • Create New...