Doxie Posted January 29, 2019 Share Posted January 29, 2019 Hi, I'm going crazy... I have not worked with AutoIT for many many years, and my brain is about to explode. I'm trying to get the result from a wmic displayed in GUICtrlCreateInput, but i dont understand how to do it. All my commands works fine in bat file, but i fail to understand how i can get the result in my GUI window. For example: wmic cpu loadpercentage wmic ComputerSystem get TotalPhysicalMemory wmic OS get FreePhysicalMemory wmic OS get LastBootUpTime All ideas are welcome, i'm not requesting anyone to write the code for me, just point me in the right direction. Thanks in advance Were ever i lay my script is my home... Link to comment Share on other sites More sharing options...
Danyfirex Posted January 29, 2019 Share Posted January 29, 2019 Hello. You can use Run+StderrRead or use ObjGet. Do a forum search you'll find a lot of examples. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted January 29, 2019 Share Posted January 29, 2019 @Doxie One of many examples Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Nine Posted January 29, 2019 Share Posted January 29, 2019 For FreePhysicalMemory : #include <Constants.au3> Opt ("MustDeclareVars", 1) _example () Func _example () Local $List, $Rep Local $objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2") Local $colItems = $objWMIService.ExecQuery('SELECT FreePhysicalMemory FROM Win32_OperatingSystem') If not IsObj($colItems) Then Exit MsgBox (0,"","Not an object") If not $colItems.count then Exit MsgBox (0,"","Not found") For $sItem In $colItems $List = "" For $sProperty In $sItem.Properties_ $List &= $sProperty.Name & ": " & $sProperty.Value & @CRLF Next $Rep = MsgBox ($MB_OKCANCEL,"",$List) if $Rep = $IDCANCEL then ExitLoop Next EndFunc “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Doxie Posted January 29, 2019 Author Share Posted January 29, 2019 Thanks a lot for all examples and feedback. However, i decided to go for a different solution, that its working "ok" ;$Text = systeminfo $Text = FileRead("testar2.txt") $ReportArrayDATA = StringRegExp($Text,"(?i)(?s)OS Name: (.*?)"&@CRLF&".*?Original Install Date: (.*?)"&@CRLF&".*?System Boot Time: (.*?)"&@CRLF&".*?System Model: (.*?)"&@CRLF&".*?BIOS Version: (.*?)"&@CRLF&".*?Total Physical Memory: (.*?)"&@CRLF&".*?Available Physical Memory: (.*?)"&@CRLF,1) Not working &@CRLF&".*?Hotfix(s): (.*?)" As you can see i have a file called testar2.txt that is the output of the command systeminfo, but now i have some questions. Is there a maximum of Array's i can use, if i add anymore then in the example above, i get an error message. Could the error message be because in the last array i'm trying to get Hotfix(s): (maybe its the (s) that is messing it up. The output is GUICtrlCreateInput("" & $ReportArrayDATA[0] etc, but the output is not forced to the left in the Input box, a lot of empty spaces. (but not for all results) Last but not least, is it possible to use the systeminfo command directly, instead of using it from a file, somehow load it into memory as long as the script is running. Thanks in advance Were ever i lay my script is my home... Link to comment Share on other sites More sharing options...
argumentum Posted January 29, 2019 Share Posted January 29, 2019 https://www.autoitscript.com/forum/files/file/338-scriptomatic-warraysupport/ Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Nine Posted January 30, 2019 Share Posted January 30, 2019 3 hours ago, Doxie said: However, i decided to go for a different solution, that its working "ok" I dont understand how a FileRead (...) solve your problem followed by regexp but I must be lost ! “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted January 30, 2019 Share Posted January 30, 2019 @Nine He's probably redirecting the output of the wmic query to a file, and he extracts what he needs with a RegEx Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Doxie Posted January 30, 2019 Author Share Posted January 30, 2019 38 minutes ago, FrancescoDiMuro said: @Nine He's probably redirecting the output of the wmic query to a file, and he extracts what he needs with a RegEx I'm redirecting the output of the command systeminfo to a file, and then use readfile in combonation with ReportArray. But i would love to skip the file part, and just load systeminfo into the memory, if that is even possible. Were ever i lay my script is my home... Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted January 30, 2019 Share Posted January 30, 2019 (edited) @Doxie You have been answered here, here, and here Edited January 30, 2019 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Doxie Posted January 30, 2019 Author Share Posted January 30, 2019 3 minutes ago, FrancescoDiMuro said: @Doxie You have been answered here, here, and here Ok, so based on the answer you recommend me to continue with wmic and skip "systeminfo"? Pro's with systeminfo is that i got most of the information in correct format, ex time and size. Con's is that i dont see CPU load, which force me to use wmic at some point anyway. I also need to output it to a file first, and use fileRead, which is one extra step. Pro's with wmic is that i can get everything needed Con's its more complicated and i need to adjust a lot of the result. I can read, and got some sence of idea how things work, but when it gets to complicated (not nessesary complicated for you guys) i find it hard to get a good end result. I dont enjoy to ask to most simple questions all the time, why i said point me in the right direction. With that in my mind, would you still recommend me to dive deeper into wmic and continue that path? Were ever i lay my script is my home... Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted January 30, 2019 Share Posted January 30, 2019 @Doxie You use wmic from Command Prompt; you have been suggested to use WMI Object which you can use from AutoIt, without going through Command Prompt. From there, you can query the WMI Object to obtain what you're looking for. In this way, you don't need to use output files, but directly manage the result of your query in the script. Now, it's your choice Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Nine Posted January 30, 2019 Share Posted January 30, 2019 4 hours ago, Doxie said: I can read, and got some sence of idea how things work, but when it gets to complicated (not nessesary complicated for you guys) i find it hard to get a good end result. I dont enjoy to ask to most simple questions all the time, why i said point me in the right direction. It is really not that complicated. My script is a bit too much because it is a generic tool I made for reading any class of object. It can be simplified like : Local $objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2") Local $colItems = $objWMIService.ExecQuery('SELECT * FROM Win32_OperatingSystem') If not IsObj($colItems) Then Exit MsgBox (0,"","Not an object") For $sItem In $colItems Local $FreePhysicalMemory = $sItem.FreePhysicalMemory Local $LastBootUpTime = $sItem.LastBootUpTime Next TotalPhysicalMemory comes from Win32_PhysicalMemory and loadpercentage comes from Win32_Processor class. You can get the list of all the properties in msdn : https://docs.microsoft.com/en-us/windows/desktop/cimwin32prov/win32-processor I believe you will get a sense of satisfaction by using the right tool for your need. If you take a moment to read this documentation, I think you will agree with us. But if you persist in using wmic, you can get the information into your script by reading directly from StdoutRead () Happy scripting. ps. don't worry about asking question, most ppl here enjoy helping out “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now