Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Close Windows from Batch File  (Read 3041 times)

0 Members and 1 Guest are viewing this topic.

sacramentojoe

  • Guest
Close Windows from Batch File
« on: January 10, 2008, 01:24:23 PM »
I've got a batch file that opens up about 6 other "named" windows.
I'd like to be able to create a batch file that I can run that will close these opened command prompts.

I think I've tried it all but I must be missing something.

Please help.

DaveLembke



    Sage
  • Thanked: 662
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Close Windows from Batch File
« Reply #1 on: January 10, 2008, 08:56:37 PM »
You can use Taskkill command to kill the windows with various options as shown copy/pasted from my XP system.

C:\WINDOWS>taskkill/?

TASKKILL [/S system [/U username [/P [password]]]]
         { [/FI filter] [/PID processid | /IM imagename] } [/F] [/T]

Description:
    This command line tool can be used to end one or more processes.
    Processes can be killed by the process id or image name.

Parameter List:
    /S    system           Specifies the remote system to connect to.

    /U    [domain\]user    Specifies the user context under which
                           the command should execute.

    /P    [password]       Specifies the password for the given
                           user context. Prompts for input if omitted.

    /F                     Specifies to forcefully terminate
                           process(es).

    /FI   filter           Displays a set of tasks that match a
                           given criteria specified by the filter.

    /PID  process id       Specifies the PID of the process that
                           has to be terminated.

    /IM   image name       Specifies the image name of the process
                           that has to be terminated. Wildcard '*'
                           can be used to specify all image names.

    /T                     Tree kill: terminates the specified process
                           and any child processes which were started by it.

    /?                     Displays this help/usage.

Filters:
    Filter Name   Valid Operators           Valid Value(s)
    -----------   ---------------           --------------
    STATUS        eq, ne                    RUNNING | NOT RESPONDING
    IMAGENAME     eq, ne                    Image name
    PID           eq, ne, gt, lt, ge, le    PID value
    SESSION       eq, ne, gt, lt, ge, le    Session number.
    CPUTIME       eq, ne, gt, lt, ge, le    CPU time in the format
                                            of hh:mm:ss.
                                            hh - hours,
                                            mm - minutes, ss - seconds
    MEMUSAGE      eq, ne, gt, lt, ge, le    Memory usage in KB
    USERNAME      eq, ne                    User name in [domain\]user
                                            format
    MODULES       eq, ne                    DLL name
    SERVICES      eq, ne                    Service name
    WINDOWTITLE   eq, ne                    Window title

NOTE: Wildcard '*' for the /IM switch is accepted only with filters.

NOTE: Termination of remote processes will always be done forcefully
      irrespective of whether /F option is specified or not.

Examples:
    TASKKILL /S system /F /IM notepad.exe /T
    TASKKILL /PID 1230 /PID 1241 /PID 1253 /T
    TASKKILL /F /IM notepad.exe /IM mspaint.exe
    TASKKILL /F /FI "PID ge 1000" /FI "WINDOWTITLE ne untitle*"
    TASKKILL /F /FI "USERNAME eq NT AUTHORITY\SYSTEM" /IM notepad.exe
    TASKKILL /S system /U domain\username /FI "USERNAME ne NT*" /IM *
    TASKKILL /S system /U username /P password /FI "IMAGENAME eq note*"

C:\WINDOWS>


Hope this helps!

Dave

ionic



    Rookie

    Re: Close Windows from Batch File
    « Reply #2 on: January 11, 2008, 10:54:25 AM »
    Although it does cost $$ the small program automatically closes windows, confirms dialog choices...etc without user intervention. There may very well be something like this as freeware, whoe knows...

    http://www.basta.com/ProdBuzof.htm