JakeLD Posted March 16, 2010 Posted March 16, 2010 Hi, I am trying to kill a process for the current logged user only. However I noticed that the ProcessClose command is trying to shut down all instances. I have tried the ProcessClose command with the exe name and the PID number and I get the same results. Here is my code so far. Thank you for your help. Dim $PID1, $PID2 ; Hide AutoIt tray icon AutoItSetOption("TrayIconHide", 1) ; Launch Act along with Outlook Service ShellExecute("D:\Program Files\ACT\Act for Windows\ActSage.exe", "-nosplash") ShellExecute("D:\Program Files\ACT\Act for Windows\Act.Outlook.Service.exe", @SW_HIDE) ; Kill Act.Outlook.Service.exe when ActSage.exe is closed $PID1 = ProcessExists("ActSage.exe") ; Will return the PID or 0 if the process isn't found. $PID2 = ProcessExists("Act.Outlook.Service.exe") ; Will return the PID or 0 if the process isn't found. If $PID2 Then ProcessWaitClose($PID1) ProcessClose($PID2) Exit Regards, Jonathan
ripdad Posted March 16, 2010 Posted March 16, 2010 (edited) Hi, "current logged user" implies that there are more users logged on the same computer. depending on how the process interacts between users (ie: multiple instances of the same exe) If you kill the process - you kill it for all users. Edit: I suppose there's a way around it - i'm not sure how though. My guess - get the User ID and then kill the process under it. Edited March 16, 2010 by ripdad "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward
bo8ster Posted March 16, 2010 Posted March 16, 2010 Hi,"current logged user" implies that there are more users logged on the same computer.depending on how the process interact between users (ie: multiple instances of the same exe)If you kill the process - you kill it for all users.A process is started by a user or the system. If a the same process is running for two users then really there will be 2 process running, 2 instances of the same program. If you kill one it will not effect the other. I'm not sure how to do it in AutoIt but I know the with cmd tool taskkill you can specify the user name and PID. You will have to get the current logged in user, this may be the session, tasklist /v may give you this. You have to do some reading up on this.You can use taskill with the Run() function. Do a tasklist first to see what is running. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]
Pain Posted March 16, 2010 Posted March 16, 2010 @UserName _Security__LookupAccountName With WMI: Win32_Process and use GetOwner. You can find some useful code here: http://www.autoitscript.com/forum/index.php?showtopic=19284
digitalexpl0it Posted July 17, 2015 Posted July 17, 2015 Something like this should work local $strComputer = @ComputerName ; What process to kill local $strProcessName = "notepad.exe" local $objWMI = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") local $colProcesses = $objWMI.ExecQuery("Select * from Win32_Process Where Name = '"& $strProcessName & "'") local $intCount = $colResults.Count for $objProcess in $colProcesses if $objProcess.GetOwner(@UserName, @LogonDomain) = 0 then $objProcess.Terminate() endif next ; Exit script exit
iamtheky Posted July 17, 2015 Posted July 17, 2015 (edited) While 1 If Not ProcessExists("ActSage.exe") Then run('cmd /c taskkill /F /FI "USERNAME eq ' & @USERNAME & '"' & ' /IM "Act.Outlook.Service.exe"') exitloop EndIf sleep (50) Wend Edited July 17, 2015 by boththose figured the loop should end ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
Developers Jos Posted July 17, 2015 Developers Posted July 17, 2015 You both know you are answering a 5 years+ old topic? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
iamtheky Posted July 17, 2015 Posted July 17, 2015 ohh they got me again. Fool me once shame on you, fool me for like the 8th time thats definitely me. ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
Nas Posted June 23, 2020 Posted June 23, 2020 I know this is an old topic but I just wanted to thank @digitalexpl0it, your script worked perfectly for me.
rudi Posted June 26, 2020 Posted June 26, 2020 Hm, right, old topic 🙃 Anyway: Dim $PID1, $PID2 ; Hide AutoIt tray icon AutoItSetOption("TrayIconHide", 1) ; Launch Act along with Outlook Service $PID1 = ShellExecute("D:\Program Files\ACT\Act for Windows\ActSage.exe", "-nosplash") $PID2 = ShellExecute("D:\Program Files\ACT\Act for Windows\Act.Outlook.Service.exe", @SW_HIDE) While ProcessExists($PID1) Sleep(1000) WEnd ProcessClose($PID2) Earth is flat, pigs can fly, and Nuclear Power is SAFE!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now