Jump to content
Sign in to follow this  
bordomavi

write exe files in specified folder

Recommended Posts

bordomavi

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"

Share this post


Link to post
Share on other sites
bordomavi

#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

Share this post


Link to post
Share on other sites
bordomavi

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.

Share this post


Link to post
Share on other sites
jguinch

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

Share this post


Link to post
Share on other sites
Bert

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.

Share this post


Link to post
Share on other sites
bordomavi

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

Share this post


Link to post
Share on other sites
bordomavi

I want close my all running portable apps with one click

Share this post


Link to post
Share on other sites
jguinch

#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

Share this post


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

Share this post


Link to post
Share on other sites
bordomavi

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 :( ?

Share this post


Link to post
Share on other sites
jguinch

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 ?

Share this post


Link to post
Share on other sites
bordomavi

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 :)

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  

×