Task Manager CMD.EXE Description - windows

I have a Windows batch script which issues the following command:
start "%IDT%_%IDTU%" D:\Apps\P_PROC\SNF2.BAT %IDF% %IDT% %IDTU% "%FNAME%" "%PARM%" "%NFNAME%" %PART% "%COMMENT%" %RPART%
When I go to Task Manager, the process CMD.EXE always shows a Description of "Windows Command Processor." If I have many start(s) triggering, how can I get the title from my start command as the Description in Task Manager?

Try using
tasklist /v /fi "imagename eq cmd.exe"
from the command prompt.
Or - use the applications tab rather than processes

Related

How to get name of user account running a process on Windows command line?

I parse the output of wmic to get pid (process identifier), command line, etc. of a running process. Unfortunately user name (user executing this process) is missing from wmic output.
Is there a method to get the name of the user account?
Example wmic command:
wmic process where caption="explorer.exe"
Output:
Caption CommandLine CreationClassName CreationDate ...
explorer.exe C:\Windows\Explorer.EXE Win32_Process 20180214220330. ...
One possibility is using the command TASKLIST:
tasklist /V /FI "IMAGENAME eq explorer.exe"
Run in a command prompt window tasklist /? for help on this command which explains the used options.
The same command line for usage in a batch file with full qualified file name:
%SystemRoot%\System32\tasklist.exe /V /FI "IMAGENAME eq explorer.exe"

How to kill a specific task in windows 2012 server

This is for windows 2012 server. I am trying to kill a specific task running under cmd window.
In this specific case I want to kill SWIMAUX. I have a command prompt open and every time I use taskkill command I get the following error. How can I kill that task?
C:\Siemens\hot_cold_backups>taskkill /f /fi "imagename eq SWIMAUX"
INFO: No tasks running with the specified criteria.
C:\Siemens\hot_cold_backups>taskkill /f /fi "services eq SWIMAUX"
INFO: No tasks running with the specified criteria.
You need to either specify the image name for the process you want to kill or the window title.
If the window has a specific title, then you can use the WINDOWTITLE parameter of the taskkill command
TASKKILL /F /FI "WINDOWTITLE eq SWIMAUX"
To find the image name of a process:
Open task manager and right click on the process you want to kill, and select Go to details
Find the highlighted executable and use it in your taskkill command, eg. taskkill /f /t /im process.exe
step 1:netstat -ano | findstr :
You should be known your PORT number
Step 2:taskkill /PID /F
id will be shown in the end of the TCP connection data in the result of above command

Trouble running TASKKILL from GitBash

I'm trying to create a function in my .bashrc to run in gitbash. The command I'm trying to run is:
cmd '/C TASKKILL /fi "WINDOWTITLE eq Windows Task Manager"'
I'll be changing the "Windows Task Manager" bit, but just to show what I'm trying. The command (TASKKILL /fi "WINDOWTITLE eq Windows Task Manager") works fine when I run it through Windows cmd, but when I run from gitbash, I get this error message:
ERROR: Invalid argument/option - 'eq'.
Type "TASKKILL /?" for usage.
As I said, it works fine in cmd, so I'm thinking it's something to do with the quotation marks. I've also tried the following, which also fails:
cmd "/C TASKKILL /fi \"WINDOWTITLE eq Windows Task Manager\""
I could put the command in a .bat file and run that (cmd "/C pathtofile/script.bat") and that works, but I'd prefer to run it straight from the .bashrc, if possible.
cmd "/C TASKKILL /fi "WINDOWTITLE eq Windows Task Manager""
It seems like it shouldn't work due to how the quotation marks are nested, but it does.

How do I list running applications with a DOS batch command?

Background: I use DOS START command to start MyDaemon:
#echo off
START "MyDaemon" java -cp test.jar MyTest /B
As part of this, I also want to check if MyDaemon is already running. If it is, I don't want to start it again.
The dos command that doesn't suit my requirement is:
tasklist /fi "imagename eq "MyDaemon" > nul
if errorlevel 1 start "MyDaemon" java -cp test.jar MyTest /B
and that's because, in the tasklist, the image name is "java.exe", not "MyDaemon". I am looking for the "application name" as seen in task manager, not the image name.
So how can I perform this check to see if MyDaemon is already running using DOS?
You may try:
tasklist /fi "windowtitle eq MyDaemon"
Type tasklist /? for further details.
No, you only can enumerate processes. If a process has been launched with parameters (like your'), you cannot see them.
I can give you a solution in .NET to get the application name for processes (or the title of the main window), but I don't think dos can do it.

Batch script to close all open Command Prompt windows

I have a .cmd file which I call to open multiple instances of Command Prompt via:
launcher.cmd -fs
launcher.cmd -tds
launcher.cmd -fsd
Each command open a new command prompt.
So what I want to do is create a batch file to automatically close all the opened Command Prompt instead of manually doing it.
Be carefull: you might kill more processes than you want:
taskkill /IM cmd.exe
You can add extra filters:
taskkill /IM cmd.exe /FI "WINDOWTITLE eq launcher*"
use
tasklist /FI "imagename eq cmd.exe " /V
to get a glimpse of what cmd.exe processes will be taskkill-ed
You could add the /F parameter to force the process to close but I would only use that if the process doesn't respond to a normal request.
Just a little note why accepted answer from Rene may not work. I was starting my apps from cmd file like
start "" my.exe -my -args
where my.exe was a console app and it was looking like cmd window I wanted to kill, but process name was not cmd.exe (!) and I had to use command like
taskkill /IM my.exe
So in some cases it worth to check the real process name, for example in the windows task manager.
TASKKILL /F /IM cmd.exe /T
good solution

Resources