Sign in to follow this  
Followers 0
GEOSoft

Talk About Boredom!

16 posts in this topic

#1 ·  Posted (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. :)

#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 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!"

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

Nice!

Didn't you post in support about this, or did someone else?

If you did, grats on figuring it out :(

Thanks JoshDb

It must have been someone else in support

I 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!"

Share this post


Link to post
Share on other sites

nice.. actually

please update it and make it even better

all commands.. etc ... etc

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

nice.. actually

please update it and make it even better

all commands.. etc ... etc

8)

Thanks Val

I 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!"

Share this post


Link to post
Share on other sites

nice.. actually

please update it and make it even better

all commands.. etc ... etc

8)

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!"

Share this post


Link to post
Share on other sites

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!"

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

@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.

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 ? = Help

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

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 want

with 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 checked
  • it checks for cmd because that gets handled differently
  • it 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 list

Try 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!"

Share this post


Link to post
Share on other sites

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:"


Share this post


Link to post
Share on other sites

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:"

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!"

Share this post


Link to post
Share on other sites

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?

[center]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.[/center]

Share this post


Link to post
Share on other sites

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!"

Share this post


Link to post
Share on other sites

:) Didn't we just talk about this???

:):)

[center]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.[/center]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0