Jump to content
Sign in to follow this  

Get and kill process PID when you know the username and process name

Recommended Posts

I hoping some of you young people can help an old man get off the nickel...  I have a small project I'd like to complete before I retire.  My problem is that on a terminal server environment I need to be able to detect the PID of a process by 'process name' AND 'process owner' so I can kill that specific process and not affect others who may be running the same process in another session.    I can seem to do one or the other but not both.  Can anyone please point me in the right direction?  Thanks very much in advance. -Glen

Share this post

Link to post
Share on other sites

I may be talking above my level, but if you have the capacity to detect the PID by the process name and detect the process owner - both of which I found example scripts, the way to implement killing a specific instance of that PID without affecting other kiosks would be to install an executable that is made into a service that receives TCP flags signaling to kill the process on that particular node that is determined to be disabled. On your server, you would have to set up a TCP transmitter that would send out the flag to the receiver. I have seen this work in AutoIt example scripts in the past. I'm not experienced enough to write such code on my own, but I understand the concept and can work from example scripts. I hope this can help point you in the right direction. Hopefully, someone more experienced can help you even more.

RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By TryWare90Days
      I'm trying to kill a malware process, that I can't remove with my www.sophus.com/hom antivirus.

      The malware is known as coinminer,config and my Sophus only creates popups of blocking the malware.

      I know that the malware is constantly launching a svchost *32.exe processes, where the svchost.exe processes are from my Windows 7 operating system.
      I have with no luck tried to do this:
      Global $_bStatus = False
      While $_bStatus = False
                 Global $_iPid
                 Global $_sActiveTitleNew = "svchost *32.exe"
                 $_iPid = WinGetProcess($_sActiveTitleNew)
                 If $_iPid <> -1 Then $_bStatus = ProcessClose($_iPid)   
      But the $_iPid doesn't ever show anything else than  -1, even if I can see the svchost *32.exe process in my TaskManager
      YES - I know I shouldn't EXIT after killing the first malware detection, but it is easier to explain the above for you, so I can get a solution.
    • By Jason86
      I would like to automate Putty commands whereby it will select my saved telnet session (so open Putty Configuration and select session) and afterwards it will open the Putty-prompt and will do next commands:
      ACCESS <Enter>
      'UserName' <Enter>
      SET Priv <Enter>
      'Password' <Enter>
      LOG PORT ALL <Enter>
      And close Putty
      Kind of new in AutoIT so all help is welcome !
      Thanks in advance,
    • By BlazerV60
      Hello all,
      I've written the code below which launches chrome in incognito mode and then proceeds to go to the autoit website.
      From my understanding, the Run() command is also supposed to output the PID number related to the application that got launched from the Run command.
      However when I run the below lines, it outputs a PID number that is different from the newly launched chrome browser's PID number, does anyone know why and possibly explain how I could retrieve the accurate PID number associated with the newly launched browser?
      Global $iPid = Run(@ComSpec & ' /c start chrome.exe https://www.autoitscript.com/forum/ -incognito' ,"", "") msgbox(0,"",$iPid) Thank you,
    • By Progh0st
      Is it posible to get Internet traffic from a PID, like download and upload speeds. I did some research but nothing useful. ty
    • By meows
      Func Button2Click() ;==> SonoLvl2 ******************************************************* SoundPlay(@ScriptDir & "\schoolbell.wav", 1) Local $Test2 = IniRead(@ScriptDir & "\runer.ini", "Levels", "LComplete1", "Default Value") If $Test2 = 1 Then ; $updatepid = RunWait(@ScriptDir & "\SonoLvl2\SonoLvl2_.exe", "", @SW_SHOWDEFAULT) Else MsgBox(4096, "", "You did not complete Lesson1") EndIf ;MsgBox($MB_SYSTEMMODAL, "Bug Report Environment", _DebugBugReportEnv()) IniWrite(@ScriptDir & "\runer.ini", "Levels", "LComplete2", "2") EndFunc ;==>Button2Click I have tried PID checks and updatepid per the help file and they just didn't work out. and usually caused errors. Then (not included I tried making a separate function to write to a INI file. that was a lesson in frustration and defeat. It worked.. just the same as the code in the function now. as soon as you click the button and the runwait line starts the ini gets updated. The file can only be written to after runwait is running is closed. Also tried the ProcessWait, ProcessWaitClose,  ShellExecute, ShellExecuteWait
      Then in desperation I tried a Debug i read about
      Func Button2Click() ;==> SonoLvl2 ******************************************************* $__iLineNumber=162 & ' - SoundPlay(@ScriptDir & "\schoolbell.wav", 1)•' SoundPlay(@ScriptDir & "\schoolbell.wav", 1) $__iLineNumber=163 & ' - Local $Test2 = IniRead(@ScriptDir & "\runer.ini", "Levels", ...•' Local $Test2 = IniRead(@ScriptDir & "\runer.ini", "Levels", "LComplete1", "Default Value") $__iLineNumber=164 & ' - If $Test2 = 1 Then•' If $Test2 = 1 Then $__iLineNumber=165 & ' - $updatepid = RunWait(@ScriptDir & "\SonoLvl2\SonoLvl2_.exe", ...•' $updatepid = RunWait(@ScriptDir & "\SonoLvl2\SonoLvl2_.exe", "", @SW_SHOWDEFAULT) Else $__iLineNumber=167 & ' - MsgBox(4096, "", "You did not complete Lesson1")•' MsgBox(4096, "", "You did not complete Lesson1") EndIf ;MsgBox($MB_SYSTEMMODAL, "Bug Report Environment", _DebugBugReportEnv()) $__iLineNumber=173 & ' - IniWrite(@ScriptDir & "\runer.ini", "Levels", "LComplete2", ...•' IniWrite(@ScriptDir & "\runer.ini", "Levels", "LComplete2", "2") EndFunc ;==>Button2Click unfortunately I was not smart enough to get it to work for me. What I wanted was a Debugger that explains what each line does and why. Then I figured out that isn't happening.
  • Create New...