GEOSoft Posted May 19, 2006 Share Posted May 19, 2006 (edited) I was just killing time so this took care of a few minutes. It will return the output of the command to an Edit control. If no switches for the command are specified then it returns the available switches. I know, it's probably been done before and I could have killed more time by searching the forums to find out. expandcollapse popup#cs Compiler Version: 3.1.1.123 Language: English (United States) Platform: Who Knows? Probably all Author: GEOSoft Project ; Name: ; Function: Just a toy to return the output or available switches of a command run from @ComSpec To Do: Whatever you want #ce Opt ("TrayIconDebug", 1) $Gw = 450 $Gh = 450 $Data = 'ipconfig|netstat|tracert|ping|fc|type|tree|attrib|assoc|move|find|at|arp|atmadm|bootcfg|cacls' $Data = $Data & '|change logon|change port|change user|chcp|chdir|chkdsk|chkntfs|cipher|comp' $Data = $Data & '|compact|cmd|convert|copy|cprofile|driverquery|expand|findstr|getmac|nbtstat' $Data = $Data & '|pathping|runas|systeminfo|typeperf|xcopy' GUICreate ('Get Command Output', $Gw, $Gh) $In = GUICtrlCreateCombo ('', 10, 10, 200, $Gh - 100) $Edit = GUICtrlCreateEdit ('', 10, 40, $Gw - 20, $Gh - 80) $Go = GUICtrlCreateButton ('Go', ($Gw / 2) - 30, $Gh - 30, 60, 20, 0x0001) GUICtrlSetState ($In, 256) GUICtrlSetData ($In, $Data) GUISetState () While 1 $Msg = GUIGetMsg () Switch $Msg Case - 3 Exit Case $Go If StringLen(GUICtrlRead ($In)) > 0 Then GUICtrlSetState ($Go, 144) GUICtrlSetData ($Edit, _Run (GUICtrlRead ($In))) GUICtrlSetData ($In, '|' & $Data) GUICtrlSetState ($Go, 80) Else GUICtrlSetState ($In, 256) ContinueLoop EndIf EndSwitch Wend Func _Run($Cmd) If $Cmd = 'cmd' Then $Cmd = 'cmd /?' GUICtrlSetData ($Edit, '') If StringInStr ($Cmd, '-') = 0 AND StringInStr ($Cmd, '/') = 0 Then $Run = Run (@ComSpec & ' /c ' & $Cmd & ' /?', @SystemDir, @SW_HIDE, 6) While ProcessExists($Run) Sleep(10) Wend $Line = StdErrRead ($Run) If $Line = '' then $Line = StdOutRead ($Run) Else $Run = Run (@ComSpec & ' /c ' & $Cmd, @SystemDir, @SW_HIDE, 6) While ProcessExists($Run) Sleep(10) Wend $Line = StdOutRead ($Run) If $Line = '' then $Line = StdErrRead ($Run) $Data = GUICtrlRead ($In) & '|' & $Data EndIf Return $Line EndFunc ;<==> _Run($Cmd) EDIT: Added quite a few commands to the Combo box. BTW; The only reason that $Data is split so often is to avoid line wrap problems in the post. This takes care of the request by Valuater for more commands. If you still want more then ask him to add them for you. Don't forget that if you know the name of the command you can just enter it into the combo and then run it. If you included switches it will run using those switches and if not it will list the switches for that command. Edited June 5, 2008 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
JoshDB Posted May 20, 2006 Share Posted May 20, 2006 Nice! Didn't you post in support about this, or did someone else? If you did, grats on figuring it out Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite Link to comment Share on other sites More sharing options...
GEOSoft Posted May 20, 2006 Author Share Posted May 20, 2006 Nice!Didn't you post in support about this, or did someone else?If you did, grats on figuring it out Thanks JoshDbIt must have been someone else in supportI just whipped this up (about 20 minutes) when I couldn't remember the switches for one command and I didn't feel like looking them up George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Valuater Posted May 20, 2006 Share Posted May 20, 2006 nice.. actually please update it and make it even better all commands.. etc ... etc 8) Link to comment Share on other sites More sharing options...
GEOSoft Posted May 20, 2006 Author Share Posted May 20, 2006 nice.. actuallyplease update it and make it even betterall commands.. etc ... etc8)Thanks ValI might actually get around to doing that but right now you can just add a command into the Combo and it will still run it. I just have to dig out the full list of commands and enter them into $Data George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
GEOSoft Posted May 20, 2006 Author Share Posted May 20, 2006 nice.. actuallyplease update it and make it even betterall commands.. etc ... etc8)OK the first post has been edited with the new code. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
GEOSoft Posted May 21, 2006 Author Share Posted May 21, 2006 Nice!Didn't you post in support about this, or did someone else?If you did, grats on figuring it out I have a question now I just noticed that system info is not returning the information like it does when run from a Cmd window. Any ideas? This is not urgent I'm just curious. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
ptrex Posted May 22, 2006 Share Posted May 22, 2006 @GEOSoft Correct something is not working correct ! When you select the "ping" cmd and you add the ipaddress after the cmd, it only returns the swithes and not the actual cmd output ? it would be nice to have it fixed. Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Valuater Posted May 22, 2006 Share Posted May 22, 2006 @GEOSoftCorrect something is not working correct !When you select the "ping" cmd and you add the ipaddress after the cmd, it only returns the swithes and not the actual cmd output ?it would be nice to have it fixed.that would be nice... but its not "broken"see this line$Run = Run (@ComSpec & ' /c ' & $Cmd & ' /?', @SystemDir, @SW_HIDE, 6)it tells you it will return ? = Help8) Link to comment Share on other sites More sharing options...
ptrex Posted May 22, 2006 Share Posted May 22, 2006 OK if it's not broken, might be a good idea to extend it then. So that it becomes more a CMD Shell Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
GEOSoft Posted May 22, 2006 Author Share Posted May 22, 2006 OK if it's not broken, might be a good idea to extend it then. So that it becomes more a CMD Shell It was never written as a CMD shell. The idea was to return the appropriate switches for a command for use in a script, I just figured that for an extra 5 or 6 lines of code I'd let it run the command when it could.To Do: Whatever you wantwith emphasis on the YOU.I was just killing time so this took care of a few minutes.If you look at the code you will see that there are only 3 things that are checkedit checks for cmd because that gets handled differentlyit checks for "-" (this is being deprecated by MS. Future versions will only use "/")it checks for "/"If those are not in $Cmd then it will return the switch listTry netstat -a, that will return properly.Ping is another one that needs special handling but AutoIt already has a Ping() function and there are probably others that won't run properly. I haven't tested them all. (I leave that in your hands )<tip> Don't try a ping command from this script without using the appropriate switches or you will end up locking up your system because it will never time out</tip>You are free to do what ever you want with the script. As a matter of fact I would be interested in seeing what people actually manage to turn it into.My next time waster will probably be a spell checker so this script has gone as far as I want to take it at this point. As long as it gives me the available switches I'm happy. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Jabberwock Posted June 28, 2006 Share Posted June 28, 2006 what about updating the information in the comspec? say a ping? it only seems to show the first line, the command ping -t -l 32 127.0.0.1 and then this is all the info it sends back "Pinging 127.0.0.1 with 32 bytes of data:" Link to comment Share on other sites More sharing options...
GEOSoft Posted June 5, 2008 Author Share Posted June 5, 2008 what about updating the information in the comspec? say a ping? it only seems to show the first line, the commandping -t -l 32 127.0.0.1and then this is all the info it sends back"Pinging 127.0.0.1 with 32 bytes of data:"I know it's not nice to drag up threads this old, but apparently some people are still interested in this one. Someone PMed me about the same type of problem and I have fixed it. I think it also solves the ping issue but I'm not doing any more with it right now. Or for the last two years actually. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 5, 2008 Moderators Share Posted June 5, 2008 I know it's not nice to drag up threads this old, but apparently some people are still interested in this one. Someone PMed me about the same type of problem and I have fixed it. I think it also solves the ping issue but I'm not doing any more with it right now. Or for the last two years actually. For the love of God George... 2 years??? What were you thinking? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
GEOSoft Posted June 5, 2008 Author Share Posted June 5, 2008 For the love of God George... 2 years??? What were you thinking? Didn't we just talk about this??? George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 5, 2008 Moderators Share Posted June 5, 2008 Didn't we just talk about this??? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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