find pid for processes
Moderator: DosItHelp
find pid for processes
hi
I need quick help for projects
I need a command that find Pid processes and As a variable which.
for example
find pid processes "egui" and = abc
and
I love it I use the following command
taskkill /pid %abc% /f
Because I find it And define it as a variable that pid After each time restart Change
Is it possible to do?
very thanks
I need quick help for projects
I need a command that find Pid processes and As a variable which.
for example
find pid processes "egui" and = abc
and
I love it I use the following command
taskkill /pid %abc% /f
Because I find it And define it as a variable that pid After each time restart Change
Is it possible to do?
very thanks
Re: find pid for processes
Have a look at the TASKLIST command. But why are you not simply using the image name (/im process.exe)? Why the indirect way via PID?
Regards
aGerman
Regards
aGerman
Re: find pid for processes
Because that is antivirus (nod32) process And is very strong ant not kill with /im process.
that process just kill with /pid
I want to command A process pid As variables to consider
For example
pid process egui.exe = abc
abc aVariable
؟؟؟
So thanks
that process just kill with /pid
I want to command A process pid As variables to consider
For example
pid process egui.exe = abc
abc aVariable
؟؟؟
So thanks
Re: find pid for processes
why closing the nod32 just remove it if you don't need it...?
but any way
see this:
http://www.dostips.com/forum/viewtopic.php?f=3&t=1016&start=0
and u can change the code to this :
but i dout u can kill antivirus process because they protect their process.
I didn't try.
but any way
see this:
http://www.dostips.com/forum/viewtopic.php?f=3&t=1016&start=0
and u can change the code to this :
Code: Select all
@echo off &setlocal
set "process=firefox.exe"
for /f "tokens=2" %%i in ('tasklist /nh /fi "imagename eq %process%" 2^>nul') do set PID=%%i
taskkill /F /pid %PID%
but i dout u can kill antivirus process because they protect their process.
I didn't try.
Re: find pid for processes
'
disabling the NOD service is a little more safer/friendly, see net start and net stop commands net /? and services.msc
disabling the NOD service is a little more safer/friendly, see net start and net stop commands net /? and services.msc
Re: find pid for processes
wow
Thank you very much
God give you everything you want
very Thanks
+
up command (code) find pid process and set As Variable
Now
for find pid services and set As Variable in the under code
what Should Replace (process and %process%)
im Replace (sc & net) but program Did not work properly!!!
what Should Replace (process and %process%)؟
SO Thanks

Thank you very much
God give you everything you want
very Thanks
+
up command (code) find pid process and set As Variable
Now
for find pid services and set As Variable in the under code
Code: Select all
@echo off &setlocal
set "process=firefox.exe"
for /f "tokens=2" %%i in ('tasklist /nh /fi "imagename eq %process%" 2^>nul') do set PID=%%i
taskkill /F /pid %PID%
what Should Replace (process and %process%)
im Replace (sc & net) but program Did not work properly!!!
what Should Replace (process and %process%)؟
SO Thanks
Re: find pid for processes
Because you told us you want to kill the egui.exe process you should change:
You could also append a PAUSE command to the code to see whether an error occurs.
Regards
aGerman
Code: Select all
set "process=egui.exe"
You could also append a PAUSE command to the code to see whether an error occurs.
Regards
aGerman
Re: find pid for processes
Is true،im underestand.
Excellent
I Except up code ,i a new code want till Instead process pid , find service pid!!
Instead "process=service" What code do؟
Excellent
Code: Select all
set "process=egui.exe"
I Except up code ,i a new code want till Instead process pid , find service pid!!
Instead "process=service" What code do؟
Re: find pid for processes
What are you doing with the PID of a service? You cannot apply TASKKILL on services. You have to use NET STOP instead as Ed already suggested.
Regards
aGerman
Regards
aGerman
Re: find pid for processes
hi,
I don't know how to get pid of a service and not all services has a pid number
stopping service with one of two command sc or net
you can stop services as a German and Ed Dyreen said
or
these two command dosn't require pid number.
you will need administrator privilage to use these commands if using windows 7
I don't know how to get pid of a service and not all services has a pid number
stopping service with one of two command sc or net
you can stop services as a German and Ed Dyreen said
Code: Select all
net stop servicename
or
Code: Select all
use sc stop servicename
these two command dosn't require pid number.
you will need administrator privilage to use these commands if using windows 7
Re: find pid for processes
abc0502 wrote:I don't know how to get pid of a service
Code: Select all
set "service=Schedule"
for /f "skip=1 delims=" %%i in ('wmic service where name^="%service%" get ProcessID') do set /a PID = %%i
echo %PID%
... but I don't know what this information could be good for

Regards
aGerman
Re: find pid for processes
@aGerman
I used the code but it come up with this line before showing the pid number
do you know why? thanks
I used the code but it come up with this line before showing the pid number
Code: Select all
Missing operand.
976
do you know why? thanks
Re: find pid for processes
With this I get the following. I'm not sure why either. I certainly have the Workstation service running.
Code: Select all
@echo off
set "service=Schedule"
set "service=Workstation"
for /f "skip=1 delims=" %%i in ('wmic service where name^="%service%" get ProcessID') do set /a PID = %%i
echo %PID%
pause
No Instance(s) Available.
Re: find pid for processes
@abc0502
As I had to learn the output of different wmic versions have differently formatted character encodings. Sometimes it results in strange line breaks (like <CR><CR><LF>). The error you see is probably caused by such a control character that SET /A cannot process. The simpliest way is to redirect the message to NUL.
@foxidrive
Not each service runs with a PID. Have a look at the services-tab in your taskmanager before.
Regards
aGerman
As I had to learn the output of different wmic versions have differently formatted character encodings. Sometimes it results in strange line breaks (like <CR><CR><LF>). The error you see is probably caused by such a control character that SET /A cannot process. The simpliest way is to redirect the message to NUL.
Code: Select all
for /f "skip=1 delims=" %%i in ('wmic service where name^="%service%" get ProcessID') do set /a PID = %%i 2>nul
@foxidrive
Not each service runs with a PID. Have a look at the services-tab in your taskmanager before.
Regards
aGerman
Re: find pid for processes
it work fine now
thanks
thanks
