kill 1 cmd when i have several

Posted on 2011-10-31
Last Modified: 2012-06-27
am trying to kill one cmd when several are open. only way i think i could do it is if i were to specify the the window title, but dont know how. can do it in batch.
eg in batch, would have this: taskkill.exe /F /FI "<title>" /T
what would I do in powershell?
stop-process -Name cmd
then what?
Question by:marexit
    LVL 5

    Expert Comment

    The command is simply:

    title "ANY WINDOW TITLE"

    Open in new window

    LVL 5

    Expert Comment

    LVL 67

    Accepted Solution

    get-process "cmd*" | ? { $_.MainWindowTitle -like "Begin of title" } | stop-process

    Open in new window

    That is you need to get the list of processes, filter that for the title, and then stop the resulting process(es).

    Author Closing Comment

    @d_nedelchev: that was more in reverse and didnt apply to me, but was interesting - will save that one

    @Qlemo: great. didnt work exactly - had to use the -name parameter infront of the "cmd*" to get it working. thanks!!
    LVL 67

    Expert Comment

    Strange. On my PS 2.0 it worked without -name. Are you using PS 1? If so, I strongly encourage you to upgrade.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Group Policy Delegation Recently, I was tasked with delegating permissions for a specific group of administrators to a specific list of Group Policy Objects(GPO). A couple of things need to happen here for this to work. If you want the Administrat…
    A commonly asked question on the site recently has been regarding how do I share the GAL between different forests? I want a list of Contacts representing all the users in a remote domain, How do i get them? It's a problem I was posed with a litt…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now