Jump to content
Sign in to follow this  

Process overload when running commands through switch

Recommended Posts

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

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

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.

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.


Share this post

Link to post
Share on other sites


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()
            Case $idMsg = $GUI_EVENT_CLOSE
                MsgBox($MB_SYSTEMMODAL, "", "Dialog was closed")
            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

Edited by Spider001

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  

  • Create New...