Jump to content
Sign in to follow this  
LzY

The process PID and service questions

Recommended Posts

LzY

How do I get a service corresponding to the process PID number? exp:

I want to get the "DcomLaunch" and "TermService" service corresponding to the svchost.exe process's PID. How will i to do ? thanks

Share this post


Link to post
Share on other sites
Ascend4nt

If you have 'tasklist' available on your PC, you can use that to quickly output the services associated with each PID (with the '/svc' switch), which you can then parse.

You could also try out the Windows Services UDF by GEOSoft.

Share this post


Link to post
Share on other sites
LzY

If you have 'tasklist' available on your PC, you can use that to quickly output the services associated with each PID (with the '/svc' switch), which you can then parse.

You could also try out the Windows Services UDF by GEOSoft.

thanks , I have the batch for that ,How do I convert it to au3 ? thanks !

for /f "tokens=2 delims= " %%a in ('tasklist/svc^|find ^"TermService^"') do (taskkill /pid %%a /f)

Share this post


Link to post
Share on other sites
JoHanatCent

thanks , I have the batch for that ,How do I convert it to au3 ? thanks !

for /f "tokens=2 delims= " %%a in ('tasklist/svc^|find ^"TermService^"') do (taskkill /pid %%a /f)

Why would you want to kill all scheduled tasks in Vista?

If above is valid you can use _RunDOS


Share this post


Link to post
Share on other sites
LzY

Why would you want to kill all scheduled tasks in Vista?

If above is valid you can use _RunDOS

thanks ,it's work in the xp system ,Can you tell me how to convert it with _RunDOS ? I'm the Novice..

Share this post


Link to post
Share on other sites
LzY

Why would you want to kill all scheduled tasks in Vista?

If above is valid you can use _RunDOS

for /f "tokens=2 delims= " %%a in ('tasklist/svc^|find ^"TermService^"') do (taskkill /pid %%a /f)

The batch means to find the 'TermService' service corresponding to the process PID from all the processes , and kill it.

Share this post


Link to post
Share on other sites
Ascend4nt

You can run the command prompt from AutoIt and put that line without doubling up on the %'s (batch files need two %'s in 'for' statements, direct commands don't).

Try something like this:

Run(@ComSpec&' /c for /f "tokens=2 delims= " %a in (''tasklist/svc^|find ^"TermService^"'') do (taskkill /pid %a /f)')

You might replace /c with /k to ensure it's working, and then hide the window with @SW_HIDE.

Share this post


Link to post
Share on other sites
LzY

You can run the command prompt from AutoIt and put that line without doubling up on the %'s (batch files need two %'s in 'for' statements, direct commands don't).

Try something like this:

Run(@ComSpec&' /c for /f "tokens=2 delims= " %a in (''tasklist/svc^|find ^"TermService^"'') do (taskkill /pid %a /f)')

You might replace /c with /k to ensure it's working, and then hide the window with @SW_HIDE.

thank you very match......

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.