[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

kill 1 cmd when i have several

Posted on 2011-10-31
5
Medium Priority
?
423 Views
Last Modified: 2012-06-27
hi
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?
thanks
0
Comment
Question by:marexit
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:d_nedelchev
ID: 37058031
The command is simply:


title "ANY WINDOW TITLE"

Open in new window

0
 
LVL 5

Expert Comment

by:d_nedelchev
ID: 37058052
0
 
LVL 71

Accepted Solution

by:
Qlemo earned 1500 total points
ID: 37058204
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).
0
 

Author Closing Comment

by:marexit
ID: 37061687
@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!!
0
 
LVL 71

Expert Comment

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

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the adminiā€¦
Loops Section Overview

834 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