Chorda Posted October 13, 2008 Share Posted October 13, 2008 Hmm this one puzzles me... I have two processes with the same name (miranda32.exe) and my script only closes one. In order to close both I have to open a msgbox in my loop. CODE For $AppCounter = 1 To $AppList[0] ; list of all my processes ; $Executable includes the entire path $Executable = $AppExecutable[$AppCounter] ; ; $Process is the name of the executable. Remove the whole path and keep the .exe $Process = StringReplace($Executable,StringLeft($Executable,StringInStr($Executable,"\",0,-1)),"") $PID = ProcessExists($Process) ;msgbox(0, "Closing Programs", "Closing " & $Process) If $PID Then ProcessClose($Process) Next So, when this msgbox is there, both processes are closed. But as soon as I comment out the msgbox, only one of the two processes is closed. I also tried changing $Process by $PID in If $PID Then ProcessClose($Process), but it does not work either. (I've also tried a bunch of other things). Thanks Link to comment Share on other sites More sharing options...
FaT3oYCG Posted October 13, 2008 Share Posted October 13, 2008 try adding a sleep where the msgbox is something like Sleep(10) may be sufficient, but i dont know try and find a value that works 100 should be ok if 10 doesnt work but it depends how many processes you have how long the time to close them all would be if you have a high sleep value, but as i said find one that works. if its only 2 processes then just use 100 or maybe more. take into account that 1000 is 1 second Interpreters have great power!Although they live in the shadow of compiled programming languages an interpreter can do anything that a compiled language can do, you just have to code it right. Link to comment Share on other sites More sharing options...
spudw2k Posted October 13, 2008 Share Posted October 13, 2008 how about something like this? #include <Process.au3> $procname = "notepad.exe" $winlist = WinList() For $i = 1 to $winlist[0][0] $pid = WinGetProcess($winlist[$i][1]) If _ProcessGetName($pid) = $procname Then ProcessClose($pid) Next Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Chorda Posted October 13, 2008 Author Share Posted October 13, 2008 Got it. I had tried with a Sleep(2000), but it didn't seem to work that well. So since it is that processes take whatever time they need to close, I just added a while loop like this: If $PID Then ProcessClose($Process) While ProcessExists($PID) WEnd So, now it just waits until the process has terminated. Thanks a lot for pointing that out. Link to comment Share on other sites More sharing options...
spudw2k Posted October 13, 2008 Share Posted October 13, 2008 I think a prob also is hat you re calling Process exists against a string (miranda32.exe). It can be unreliaable when multiple instances are running. However WinList() returns Handles ([n][1]) instead which are unique. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Richard Robertson Posted October 13, 2008 Share Posted October 13, 2008 You can use ProcessList("miranda32.exe") to return an array of all processes of that name. Link to comment Share on other sites More sharing options...
spudw2k Posted October 13, 2008 Share Posted October 13, 2008 You can use ProcessList("miranda32.exe") to return an array of all processes of that name.Even betta. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
November Posted October 14, 2008 Share Posted October 14, 2008 Hi there. ProcessClose only works with processes open with the same user name that is running the sript for now. Bug 501 solved in beta 3.2.13.8 Cheers Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font] Link to comment Share on other sites More sharing options...
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