Sign in to follow this  
Followers 0
Spikeedoodles

Process overload when running commands through switch

7 posts in this topic

Hey there, I am making a tool that automates commands on the command prompt.  Here is an example:

While 1
      Switch GUIGetMsg()
         Case $GUI_EVENT_CLOSE
            Exit
         Case $b_ipconfig
            Call ("ipconfig")
         Case $b_netstat
            Call ("netstat")
         Case $b_arp
            Call ("arp")
         Case $b_proc
            Call ("tasklist")
         Case $b_user
            Call ("user")
         Case $b_group
            Call ("localgroup")
         Case $b_sysinfo


      EndSwitch
   WEnd
EndFunc
Func ipconfig()
   Run(@ComSpec & " /c " & 'ipcofig > '&$path&"ipconfig.txt", "", @SW_HIDE)
EndFunc
Func netstat()
   Run(@ComSpec & " /c " & 'netstat -an> '&$path&"netstat.txt", "", @SW_HIDE)
EndFunc
Func arp()
   Run(@ComSpec & " /c " & 'arp -a > '&$path&"arp.txt", "", @SW_HIDE)
EndFunc
Func tasklist()
   Run(@ComSpec & " /c " & 'tasklist > '&$path&"proc.txt", "", @SW_HIDE)
EndFunc
Func user()
   Run(@ComSpec & " /c " & 'net user > '&$path&"users.txt", "", @SW_HIDE)
EndFunc
Func localgroup()
   Run(@ComSpec & " /c " & 'net localgroup > '&$path&"group.txt", "", @SW_HIDE)
EndFunc

When I run the tool, I get completely overloaded by these "Console Window Host" (conhost.exe) applications that almost crash my PC if I dont stop the script quick enough.  What are these and how can I make them not appear?  Originally I made the Run commands happen within a switch but moved them to separate functions to see if that would help .... it didnt.

Share this post


Link to post
Share on other sites



I might consider putting a sleep inside the While loop.

Share this post


Link to post
Share on other sites

I might consider putting a sleep inside the While loop.

There is one already by using GUIGetMsg().

The issue is it keeps shelling CMD sesions which could be trigger by giving the script the "wrong" name.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

https://www.autoitscript.com/autoit3/docs/functions/GUIGetMsg.htm

i use $idMsg = GUIGetMsg() this way i had the same problem like you a long time ago.

i use it normal, the moment i got problems i use it this way and it works then

Local $idMsg = 0
    ; In this message loop we use variables to keep track of changes to the radios, another
    ; way would be to use GUICtrlRead() at the end to read in the state of each control
    While 1
        $idMsg = GUIGetMsg()
        Select
            Case $idMsg = $GUI_EVENT_CLOSE
                MsgBox($MB_SYSTEMMODAL, "", "Dialog was closed")
                ExitLoop
            Case $idMsg = $GUI_EVENT_MINIMIZE
                MsgBox($MB_SYSTEMMODAL, "", "Dialog minimized", 2)
            Case $idMsg = $GUI_EVENT_MAXIMIZE
                MsgBox($MB_SYSTEMMODAL, "", "Dialog restored", 2)

            Case $idMsg = $idButton_1
                MsgBox($MB_SYSTEMMODAL, "", "Default button clicked:" & @CRLF & "Radio " & $iRadioVal1)

            Case $idMsg >= $idRadio_1 And $idMsg <= $idRadio_3
                $iRadioVal1 = $idMsg - $idRadio_1

        EndSelect
    WEnd
Edited by Spider001

Share this post


Link to post
Share on other sites

Did you try RunWait instead of Run ?

Share this post


Link to post
Share on other sites

Instead of coming up with irrelevant suggestions, wait until the OP posts the script he's using.

My bet is one of his controls doesn't exist, and one of his case statements is running a program with the same name as his compiled script (probably using the non-existent control ID). But, like the rest of you, it's just a guess and we don't have nearly enough information yet to be giving suggestions to the OP.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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