Jump to content

write exe files in specified folder


Go to solution Solved by jguinch,

Recommended Posts

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 post
Share on other sites

#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 post
Share on other sites

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
Link to post
Share on other sites

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.

Link to post
Share on other sites

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 post
Share on other sites
  • Solution

#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 by jguinch
Link to post
Share on other sites
#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 post
Share on other sites

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 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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...