Sign in to follow this  
Followers 0
BZU

Process.au3 usage question. Getting PID And Kill a Process.

10 posts in this topic

hi,

i have running two processes running with the same name from different locations.

how can i get process id from the desired location of process.

how can i kill a system process which is running from user .

like : if process name is SMSS.EXE then windows will disallow to kill it.

how can i kill it because ProcessClose fails to kill it.

please help me in this situation.

thanx


OS: Windows XP SP2, AutoIt version: 3.2.10.0Help The Great Forum Which is Used by You For Help.01 - Always Respect The Forum Members.02 - Use Search Before Posting or making any new Thread.03 - Help The Newbies.

Share this post


Link to post
Share on other sites



Windows errors related to smss.exe?

smss.exe is a process which is a part of the Microsoft Windows Operating System. It is called the Session Manager Subsystem and is responsible for handling sessions on your system. This program is important for the stable and secure running of your computer and should not be terminated.

Better have a good reason for closing it...

Share this post


Link to post
Share on other sites

hi,

i have running two processes running with the same name from different locations.

how can i get process id from the desired location of process.

I think Larry wrote this a while ago

Func _ProcessGetLocation($iPID)
    Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID)
    If $aProc[0] = 0 Then Return SetError(1, 0, '')
    Local $vStruct = DllStructCreate('int[1024]')
    DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int_ptr', 0)
    Local $aReturn = DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048)
    If StringLen($aReturn[3]) = 0 Then Return SetError(2, 0, '')
    Return '"' & FileGetLongName ( $aReturn[3] ) & '"'
EndFunc

You would use it in conjunction with ProcessList() to get the desired duplicated process names to PID

Share this post


Link to post
Share on other sites

not helpfull


OS: Windows XP SP2, AutoIt version: 3.2.10.0Help The Great Forum Which is Used by You For Help.01 - Always Respect The Forum Members.02 - Use Search Before Posting or making any new Thread.03 - Help The Newbies.

Share this post


Link to post
Share on other sites

not helpfull

How the F**K do you come to that conclusion?

I have provided you with a function which supplies the path from a PID.

You use ProcessList() to get an array of processes and you loop through the array until you find the process name you want. Then you pass the PID to the supplied function to get the path of the PID.

Still looks like you don't need anymore help anyway

Share this post


Link to post
Share on other sites

not helpfull

#include <WinAPI.au3>

;Close existing process with the same, but not the parent.
$parent = _WinAPI_GetCurrentProcessID();get the parent process ID
$procArr = ProcessList (@Scriptname)

;Loop through and kill any processes of the same name but without the same PID as the parent.
For $i = 1 to Ubound($procArr) - 1
    If $procArr[$i][1] <> $parent then ProcessClose($procArr[$i][0])
Next

By the way, no one here is required to offer you help. Especially if you're rude. Think about that the next time you ask.

-John

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

The ironic thing is have you read his signature

Yeah I noticed that just after posting. Good Stuff.

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

ok , now i have got it.

thanks for the help!


OS: Windows XP SP2, AutoIt version: 3.2.10.0Help The Great Forum Which is Used by You For Help.01 - Always Respect The Forum Members.02 - Use Search Before Posting or making any new Thread.03 - Help The Newbies.

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  
Followers 0