Jump to content

Vivaed

Active Members
  • Posts

    21
  • Joined

  • Last visited

Everything posted by Vivaed

  1. This looks promising, there is a AD.au3 missing? Where do I get this.
  2. I'm a tad confused, I have TeamViewer running on my task bar and I want to right clich on it and then open a menu item it lists. However this code does not pend results for me. I am assuming that the ToolTip is the the Name that is shown when you "hover" over the icon in the tray, is this correct? Sorry for the cut image:
  3. Thanks for the info. The issue at this point is its not displaying the correct information, it returns 0.0.0.0 for all even if the version is 4.0.0.18 In my example I run the function, then I run the FileGetVersion on just on file and the two outputs are different.
  4. I am trying to read all the files in a folder, then whatever file is newest, keep only that one and delete the rest. Example files: (these all have version numbers embedded in them, I dont want to rely on the file name) Faint.exe Faint-v2.0.exe Faint-v3.0.exe Faint-v4.0.exe What I have so far: #include <File.au3> RemoveOldFiles() ConsoleWrite(FileGetVersion("C:\WB Resources\FAINT_DONT_LINK_THESE\Faint-v4.0.0.exe") &@CRLF) Func RemoveOldFiles() Local $aFileList = _FileListToArray("C:\WB Resources\FAINT_DONT_LINK_THESE\", "*.exe",$FLTA_FILES) For $i = 0 To UBound($aFileList) - 1 $aFileVersion = FileGetVersion($aFileList[$i]) ConsoleWrite($aFileList[$i] & @CRLF) ConsoleWrite($aFileVersion & @CRLF) Next EndFunc OUTPUT: >Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\Users\bot\ownCloud\WellBeats\Delete Old Files\delete-test.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop 3 0.0.0.0 a.exe 0.0.0.0 b.exe 0.0.0.0 Faint-v4.0.0.exe 0.0.0.0 4.0.0.18 <-- This is the correct file version.... +>07:34:26 AutoIt3.exe ended.rc:0 +>07:34:26 AutoIt3Wrapper Finished. >Exit code: 0 Time: 0.6647 Not sure what I am missing here? Thanks!
  5. BOOM!!!! Worked! Thank you!!!
  6. Still barking an error about the space: C:\WB : The term 'C:\WB' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + C:\WB Resources\Wellbeats.Universal_2.2.41.0_Prod\Wellbeats.Universal ... + ~~~~~ + CategoryInfo : ObjectNotFound: (C:\WB:String) [], CommandNotFou ndException + FullyQualifiedErrorId : CommandNotFoundException My code: $iDir = "C:\WB Resources\Wellbeats.Universal_2.2.41.0_Prod\Wellbeats.Universal_2.2.41.0_Prod\Add-AppDevPackage.ps1" Run('cmd /k C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command ' & '"' & $iDir & '"') I wish I could change the space but we have 2000 systems in the field with this naming convention
  7. Just tried it, didnt see a window or anything, not sure if even ran, but the app is not installed
  8. Keeps throwing an error about the space between C;\WB and Resources C:\Windows\System32\WindowsPowerShell>powershell.exe -Command "C:\WB Resources\APP_Prod\Add-AppDevPackage.ps1" C:\WB : The term 'C:\WB' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + C:\WB Resources\Wellbeats.Universal_2.2.41.0_Prod\Wellbeats.Universal ... + ~~~~~ + CategoryInfo : ObjectNotFound: (C:\WB:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException # I am running As Admin # I also triple checked the path and all spelling, everything looked good
  9. Not showing, the window closes when it errors, I wish I could pump the output to the console... is that possible?
  10. This gets the Shell to open, I see red text with errors but it closes, thanks for the progress!
  11. Trying to automate the sideload of a Windows Store app via .ps1 script... RunWait(@ComSpec & ' /c' & 'C:\"WB Resources"\APP_Prod\Add-AppDevPackage.ps1') Above doesn't work... I assume this is trying to open in CMD. Normally we right click the .ps1 and open with powershell, then we have to type "A" to start the install, it installs and then type any yet to exit. However I cant get the powershell to even open. Kind of puzzled here, any suggestions would be a help. PS I also tried to convert the .ps1 to exe, but that was a huge failure... lol
  12. I have this button in an app I am building: When you click it, it then opens a FileOpenDialog() I select and XML, then it asks for a name input, enter the name, then it should run the following code: schtasks.exe /create /tn XXXX-task /XML C:\WBRESO~1\WB-LOO~1\TESTIN~1.XML It works when I put it in the CMD and run it, I get SUCCESS! and the new task has been created in Task Scheduler. C:\Users\vivaed>schtasks.exe /create /tn XXXX /xml C:\WBRESO~1\WB-LOO~1\TESTIN~1.XML SUCCESS: The scheduled task "XXXX" has successfully been created. But when I run it in: (This is just a snippet of the code, there is a lot more) #include <AutoItConstants.au3> Global $wbResources = 'C:\"WB Resources"\WB-LoopChecker\' Case $Button4 $getXML = FileOpenDialog("Find task to import", $wbResources ,"XML (*.xml)") If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No file was selected.") Else Local $taskName = InputBox("Name this task","File: " & @CRLF & $getXML & @CRLF & "Name this task:" & @CRLF,"XXXX-task") $schedTask = 'schtasks.exe /create /tn ' & $taskName & ' /XML ' & FileGetShortName($getXML) Run(@ComSpec & " /c " & $schedTask, @SW_HIDE) ConsoleWrite($wbResources & @CRLF) ConsoleWrite($schedTask & @CRLF) EndIf Here I dont get any errors but the when I refresh the Task Scheduler, there is no new task....
  13. @kylomas Thanks for the insight! I have been reading ton about these functions. This script is interesting, it outputs all of the FAILED found but doesn't filter them by only showing the ones from the last 15 mins. since you used _NowCalcDate(), but if I change it to just _NowCalc() I get the results I am looking for. I am very grateful for the code comments, they help me understand what is what and why things are happening!!!
  14. Its weird but I just put the snippet of code in the original IF statement: If FileExists($fileLog) Then $contents = FileRead($fileLog) If @error Then MsgBox(0, 'File Error', $fileLog & ' could not be read.') Else For $i = 1 To _FileCountLines($fileLog) $result = StringInStr($contents,$search) If $result >= 1 Then $filteredLine = FileReadLine($fileLog,$i) If StringInStr($filteredLine,$search) Then For $sLine In $aFile $aTemp = StringSplit($sLine, ">") $sTime = $aTemp[1] ConsoleWrite($sTime & @CRLF) ;~ FileWrite($file_output,$filteredLine & @CRLF) Local $theDiff = _DateDiff('n', $sTime, _NowCalc()) Next If $theDiff < 15 Then ConsoleWrite($filteredLine & " " & $theDiff & " " & @CRLF) Else EndIf EndIf Else ConsoleWrite( $search & " not found!" & @CRLF) FileWrite($file_output,$search & " not found!" & @CRLF) EndIf Next EndIf FileClose($file_output) EndIf AND ITS OUTPUTTING????? (Kind of) 37 NOW CALC TIME 2016/08/23 12:06:22 2016/08/23 09:01:23 2016/08/23 09:09:28 2016/08/23 09:10:36 2016/08/23 09:11:38 2016/08/23 09:11:41 2016/08/23 09:12:43 2016/08/23 09:14:45 2016/08/23 09:29:45 2016/08/23 09:29:50 2016/08/23 09:29:55 2016/08/23 09:30:33 2016/08/23 09:01:23 2016/08/23 09:09:28 2016/08/23 09:10:36 2016/08/23 09:11:38 2016/08/23 09:11:41 2016/08/23 09:12:43 2016/08/23 09:14:45 2016/08/23 09:29:45 2016/08/23 09:29:50 2016/08/23 09:29:55 2016/08/23 09:30:33 2016/08/23 09:01:23 2016/08/23 09:09:28 2016/08/23 09:10:36 2016/08/23 09:11:38 2016/08/23 09:11:41 2016/08/23 09:12:43 2016/08/23 09:14:45 2016/08/23 09:29:45 2016/08/23 09:29:50 2016/08/23 09:29:55 2016/08/23 09:30:33 2016/08/23 09:01:23 2016/08/23 09:09:28 2016/08/23 09:10:36 2016/08/23 09:11:38 2016/08/23 09:11:41 2016/08/23 09:12:43 2016/08/23 09:14:45 2016/08/23 09:29:45 2016/08/23 09:29:50 2016/08/23 09:29:55 2016/08/23 09:30:33 2016/08/23 09:01:23 2016/08/23 09:09:28 2016/08/23 09:10:36 2016/08/23 09:11:38 2016/08/23 09:11:41 2016/08/23 09:12:43 2016/08/23 09:14:45 2016/08/23 09:29:45 2016/08/23 09:29:50 2016/08/23 09:29:55 2016/08/23 09:30:33 2016/08/23 09:01:23 2016/08/23 09:09:28 2016/08/23 09:10:36 2016/08/23 09:11:38 2016/08/23 09:11:41 2016/08/23 09:12:43 2016/08/23 09:14:45 2016/08/23 09:29:45 2016/08/23 09:29:50 2016/08/23 09:29:55 2016/08/23 09:30:33 2016/08/23 09:01:23 2016/08/23 09:09:28 2016/08/23 09:10:36 2016/08/23 09:11:38 2016/08/23 09:11:41 2016/08/23 09:12:43 2016/08/23 09:14:45 2016/08/23 09:29:45 2016/08/23 09:29:50 2016/08/23 09:29:55 2016/08/23 09:30:33 2016/08/23 09:01:23 2016/08/23 09:09:28 2016/08/23 09:10:36 2016/08/23 09:11:38 2016/08/23 09:11:41 2016/08/23 09:12:43 2016/08/23 09:14:45 2016/08/23 09:29:45 2016/08/23 09:29:50 2016/08/23 09:29:55 2016/08/23 09:30:33 2016/08/23 09:01:23 2016/08/23 09:09:28 2016/08/23 09:10:36 2016/08/23 09:11:38 2016/08/23 09:11:41 2016/08/23 09:12:43 2016/08/23 09:14:45 2016/08/23 09:29:45 2016/08/23 09:29:50 2016/08/23 09:29:55 2016/08/23 09:30:33 2016/08/23 09:01:23 2016/08/23 09:09:28 2016/08/23 09:10:36 2016/08/23 09:11:38 2016/08/23 09:11:41 2016/08/23 09:12:43 2016/08/23 09:14:45 2016/08/23 09:29:45 2016/08/23 09:29:50 2016/08/23 09:29:55 2016/08/23 09:30:33 2016/08/23 09:01:23 2016/08/23 09:09:28 2016/08/23 09:10:36 2016/08/23 09:11:38 2016/08/23 09:11:41 2016/08/23 09:12:43 2016/08/23 09:14:45 2016/08/23 09:29:45 2016/08/23 09:29:50 2016/08/23 09:29:55 2016/08/23 09:30:33 +>12:06:22 AutoIt3.exe ended.rc:0 +>12:06:22 AutoIt3Wrapper Finished. >Exit code: 0 Time: 0.8868 I think this needs to be after FileRead??? I dont really know... But this gets me a step closer lol
  15. @JLogan3o13 No it does not, looks like it passes right over it I will do more research on FileReadArray
  16. This? Local $aFile = FileReadToArray($fileOutput) ConsoleWrite(_ArrayDisplay($aFile))
  17. Okay, I have the fist part working (Read log get FAILED lines and make new file with all FAILED lines): #include <File.au3> #include <Array.au3> #NoTrayIcon #include <AutoItConstants.au3> #include <TrayConstants.au3> #include <FileConstants.au3> #include <Date.au3> #include <WinAPIFiles.au3> Global $file_output = FileOpen("C:\WB Resources\" & @ComputerName & "-FAILED-output.txt", 1) Global $file_output_wipe = FileOpen("C:\WB Resources\" & @ComputerName & "-FAILED-output.txt", 2) Global $fileLog = "C:\WB Resources\" & @ComputerName & "-WBLog.txt" Global $fileOutput = "C:\WB Resources\" & @ComputerName & "-FAILED-output.txt" $search = "FAILED" Global $aFile = FileReadToArray($fileOutput) Global $sTemp = '' ConsoleWrite(_FileCountLines($fileLog) & @CRLF) ConsoleWrite("NOW CALC TIME " & @CRLF & _NowCalc() & @CRLF) If FileExists($fileLog) Then $contents = FileRead($fileLog) If @error Then MsgBox(0, 'File Error', $fileLog & ' could not be read.') Else For $i = 1 To _FileCountLines($fileLog) $result = StringInStr($contents, $search) If $result >= 1 Then $filteredLine = FileReadLine($fileLog, $i) If StringInStr($filteredLine, $search) Then FileWrite($fileOutput,$filteredLine & @CRLF) EndIf Else ConsoleWrite($search & " not found!" & @CRLF) FileWrite($file_output_wipe, $search & " not found!" & @CRLF) EndIf Next EndIf EndIf ;~ ----------------------------------------------BROKEN ;~ For $sLine In $aFile ;~ $aTemp = StringSplit($sLine, ">") ;~ $sTime = $aTemp[1] ;~ ConsoleWrite($sTime & @CRLF) ;~ FileWrite($file_output_wipe,$sTime & @CRLF) ;~ Local $theDiff = _DateDiff('n', $sTime, _NowCalc()) ;~ Next ;~ If $theDiff <= 15 Then ;~ ConsoleWrite($filteredLine & " " & $theDiff & " " & @CRLF) ;~ FileWrite($file_output,$filteredLine & @CRLF) ;~ Else ;~ EndIf ;~ ----------------------------------------------BROKEN FileClose($file_output) Exit But as you can see the bottom FOR statement doesn't work ( when un-commented lol ) Console Output: (65) : ==> Variable must be of type "Object".: For $sLine In $aFile For $sLine In $aFile^ ERROR ->09:45:23 AutoIt3.exe ended.rc:1 +>09:45:23 AutoIt3Wrapper Finished. >Exit code: 1 Time: 0.8435 I am missing something very obvious aren't I?
  18. @kylomas Thanks for the reply! Another application checks to see if a process is running every minute and logs if [PASS] or [FAILED] Then this app checks every 15 mins. It looks for if there were any fails in the last 15 mins, if so then email support team. @jchd The log files are short for now, I could see them potentially getting long, but I would just delete them until another solution was created.
  19. Interesting, I will have to learn more about this StringSplit() Thanks for the insight, I hope it leads me down a better path lol
  20. Thanks for the Prompt response!!! @JLogan3o13 So I might not have explained it well lol 2016/08/22 13:40:00 > Process: [FAILED] 2016/08/22 13:41:00 > Process: [FAILED] 2016/08/22 13:48:00 > Process: [FAILED] 2016/08/22 13:51:00 > Process: [FAILED] 2016/08/22 14:00:00 > Process: [FAILED] Above is my actual log file Lets say my current time was 2016/08/22 14:01:00 I want to look at my log file and compare the log files time stamps to _NowCalc(), I will use _DateDiff() (But that comes later) Essentially what I am trying to do: If the log file has >= 1 FAILED log line(s) in the past 15 mins then send email with these errors inside I dont know how I parse for the date in the log file, I have tried Googled all I know #StillLearning
  21. I have another AutoIT script making a Log file Sample of Log file: 2016/08/22 12:44:18 > Process: [RUNNING] [ACTIVE] 2016/08/22 12:48:35 > Process: [WAS NOT RUNNING] 2016/08/22 13:40:00 > Process: [FAILED] 2016/08/22 14:01:10 > Process: [WAS NOT RUNNING] I am looping through the Log file for the word "FAILED" I then want to get all lines that have "FAILED" and get their TIME My Current code to get this far: If FileExists($fileLog) Then $contents = FileRead($fileLog) If @error Then MsgBox(0, 'File Error', $fileLog & ' could not be read.') Else For $i = 1 To _FileCountLines($fileLog) $result = StringInStr($contents,$search) If $result >= 1 Then $filteredLine = FileReadLine($fileLog,$i) If StringInStr($filteredLine,$search) Then ConsoleWrite($filteredLine & @CRLF) ; this gets me the results I want sans the time parse EndIf Else ConsoleWrite( $search & " not found!" & @CRLF) EndIf Next EndIf EndIf For this part: If StringInStr($filteredLine,$search) Then ConsoleWrite($filteredLine & @CRLF) ; this gets me the results I want sans the time parse EndIf OUTPUT: 2016/08/22 13:40:00 > Process: [FAILED] I dont understand how I read the time in that output? I have tried _DateTimeFormat - Dont think this applies Tried _DateDiff - I dont have a the date yet so this doesnt work Would love if someone could tell me if I am thinking is the wrong direction and possibly lead me down the correct path to light side of the force
×
×
  • Create New...