bordomavi Posted September 3, 2014 Share Posted September 3, 2014 i have a func for processclose. i want write to list from specified folder. Func _close() Local $process[12][2] = [["1.exe", ""], _ ["2.exe", ""], _ ["3.exe", ""], _ ["4.exe", ""], _ ["5.exe", ""], _ ["6.exe", ""], _ ["7.exe", ""]] For $i = 0 To UBound($process) - 1 If ProcessExists($process[$i][0]) Then ProcessClose($process[$i][0]) EndIf Next EndFunc for example write to list all exe files from @Programfiles & "Software" Link to comment Share on other sites More sharing options...
devilman16 Posted September 3, 2014 Share Posted September 3, 2014 _FileListToArrayRec(@ProgramFilesDir & "\Software\", "*|*.exe") Link to comment Share on other sites More sharing options...
bordomavi Posted September 3, 2014 Author Share Posted September 3, 2014 #include <Array.au3> ; Only required to display the arrays #include <File.au3> #include <MsgBoxConstants.au3> Local $sAutoItDir = StringLeft(@ProgramFilesDir & "\AutoIt3\", StringInStr(@ProgramFilesDir & "\AutoIt3\", "\", Default, -1)) If StringRight($sAutoItDir, 5) = "beta\" Then $sAutoItDir = StringTrimRight($sAutoItDir, 5) EndIf ConsoleWrite($sAutoItDir & @CRLF) Local $aArray = _FileListToArrayRec($sAutoItDir, "*|*.exe", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT) i found this but how can i write to in my func Link to comment Share on other sites More sharing options...
devilman16 Posted September 3, 2014 Share Posted September 3, 2014 I don't know what you are trying to do? Link to comment Share on other sites More sharing options...
bordomavi Posted September 3, 2014 Author Share Posted September 3, 2014 I don't know what you are trying to do? i said already in my first post. i want write all exe files from specified folder to 1.exe, 2.exe 3.exe.... look up ploease. Link to comment Share on other sites More sharing options...
jguinch Posted September 3, 2014 Share Posted September 3, 2014 What is wrong with the #2 ? #Include <File.au3> $aFiles = _FileListToArrayRec(@ProgramFilesDir & "\AutoIt3\", "*.exe") For $i = 1 To $aFiles[0] If ProcessExists($aFiles[$i]) Then ProcessClose($aFiles[$i]) Next Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
bordomavi Posted September 3, 2014 Author Share Posted September 3, 2014 What is wrong with the #2 ? #Include <File.au3> $aFiles = _FileListToArrayRec(@ProgramFilesDir & "\AutoIt3\", "*.exe") For $i = 1 To $aFiles[0] If ProcessExists($aFiles[$i]) Then ProcessClose($aFiles[$i]) Next it is working but if 2 .exe files are running it closes only 1 Link to comment Share on other sites More sharing options...
Bert Posted September 3, 2014 Share Posted September 3, 2014 Please do not take offense - I'm NOT saying the following is your intent, We just need clarification on how you plan to use this code. I see what you are wanting to do. We need to know WHY do you need to close a list of processes the hard way? I ask for I can see this being used for malicious purposes. For example you may want to prevent users from running a process to shut off your app. Another thing would be someone wanting to play a prank. Thanks. We have to be careful that we do not break forum rules here. The forum owner and the moderators are very careful that the rules are followed and nobody tries to tarnish AutoIt. Thanks. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
bordomavi Posted September 3, 2014 Author Share Posted September 3, 2014 Please do not take offense - I'm NOT saying the following is your intent, We just need clarification on how you plan to use this code. I see what you are wanting to do. We need to know WHY do you need to close a list of processes the hard way? I ask for I can see this being used for malicious purposes. For example you may want to prevent users from running a process to shut off your app. Another thing would be someone wanting to play a prank. Thanks. We have to be careful that we do not break forum rules here. The forum owner and the moderators are very careful that the rules are followed and nobody tries to tarnish AutoIt. Thanks. lol thanks for warning. I do not have a bad aim keep clam Link to comment Share on other sites More sharing options...
Bert Posted September 3, 2014 Share Posted September 3, 2014 lol thanks for warning. I do not have a bad aim keep clam however, you didn't answer my question. I'll ask again. Why do you need this? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
bordomavi Posted September 3, 2014 Author Share Posted September 3, 2014 I want close my all running portable apps with one click Link to comment Share on other sites More sharing options...
jguinch Posted September 3, 2014 Share Posted September 3, 2014 Look at the help file, there are at lot of functions for Process Listing. Or try to close the process until it no longer exists... Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Bert Posted September 4, 2014 Share Posted September 4, 2014 I want close my all running portable apps with one click OK, that is quite logical. Never thought of it like that. Thanks! The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Solution jguinch Posted September 4, 2014 Solution Share Posted September 4, 2014 (edited) #Include <File.au3> $aFiles = _FileListToArrayRec(@ProgramFilesDir & "\AutoIt3\", "*.exe", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_NOPATH) For $i = 1 To $aFiles[0] $aProcess = ProcessList($aFiles[$i]) For $j = 1 To $aProcess[0][0] If $aProcess[$j][1] = @AutoItPID Then ContinueLoop ProcessClose( $aProcess[$j][1]) Next Next Edited September 4, 2014 by jguinch Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
bordomavi Posted September 4, 2014 Author Share Posted September 4, 2014 #Include <File.au3> $aFiles = _FileListToArrayRec(@ProgramFilesDir & "\AutoIt3\", "*.exe") For $i = 1 To $aFiles[0] $aProcess = ProcessList($aFiles[$i]) For $j = 1 To $aProcess[0][0] ProcessClose( $aProcess[$i][1]) Next Next or #Include <File.au3> $aFiles = _FileListToArrayRec(@ProgramFilesDir & "\AutoIt3\", "*.exe") For $i = 1 To $aFiles[0] While ProcessExists($aFiles[$i]) ProcessClose($aFiles[$i]) WEnd Next first doesn't work. second closes only specified folder. doesnt close under folder. for examplae it closes in @ProgramFilesDir & "AutoIt3 exe files but if @ProgramFilesDir & "AutoIt3Example folder including another running file it doenst close. Link to comment Share on other sites More sharing options...
jguinch Posted September 4, 2014 Share Posted September 4, 2014 I don't really understand... ProcessClose() stops processes (.exe files), not folders ! Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
bordomavi Posted September 4, 2014 Author Share Posted September 4, 2014 I don't really understand... ProcessClose() stops processes (.exe files), not folders ! yes. my English bad sory. @ProgramFilesDir & "\AutoIt3\" ; it closes exe files only in this folder it must close all exe files @ProgramFilesDir & "\AutoIt3\a\" ; if .exe file in "a" folder it doesnt close this. same b and c and others in AutoIt3 folder. @ProgramFilesDir & "\AutoIt3\b\" @ProgramFilesDir & "\AutoIt3\c\" do you understand ? Link to comment Share on other sites More sharing options...
jguinch Posted September 4, 2014 Share Posted September 4, 2014 OK, I understand. My code was wrong, because I forgot to specify some parameters to _FileListToArrayRec. Also, the script closed itself (autoit3.exe). I edited my code, is it OK ? Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
bordomavi Posted September 4, 2014 Author Share Posted September 4, 2014 OK, I understand. My code was wrong, because I forgot to specify some parameters to _FileListToArrayRec. Also, the script closed itself (autoit3.exe). I edited my code, is it OK ? Yes it works perfectly thanks very much Link to comment Share on other sites More sharing options...
jguinch Posted September 4, 2014 Share Posted September 4, 2014 Please, mark your post as solved. Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF 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