Jump to content

Process using file


Recommended Posts

thx it worked :o but another problem :D if it returns "c:\pla\plapla\pla\process i need.exe"

i want the "process i need.exe" alone to use ProcessClose()

Dim $filepath, $szDrive, $szDir, $szFName, $szExt
$filepath = _WinAPI_FindExecutable ($file)
$fileexe = _PathSplit($filepath, $szDrive, $szDir, $szFName, $szExt)
$pid = _ProcessGetPid($fileexe[3] & $fileexe[4])
processclose($pid)

Func _ProcessGetPid($sName) ;borrowed
    If Not ProcessExists($sName) Then
        SetError(1)
        Return ""
    EndIf
    Local $aPList = ProcessList($sName)
    If @error Then Return ""
    Local $aMatches[UBound($aPList) ]
    $aMatches[0] = $aPList[0][0]
    For $i = 1 To $aPList[0][0]
        $aMatches[$i] = $aPList[$i][1]
    Next
    Return $aMatches
EndFunc   ;==>_ProcessGetPid
[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

Dim $filepath, $szDrive, $szDir, $szFName, $szExt
$filepath = _WinAPI_FindExecutable ($file)
$fileexe = _PathSplit($filepath, $szDrive, $szDir, $szFName, $szExt)
$pid = _ProcessGetPid($fileexe[3] & $fileexe[4])
processclose($pid)

Func _ProcessGetPid($sName) ;borrowed
    If Not ProcessExists($sName) Then
        SetError(1)
        Return ""
    EndIf
    Local $aPList = ProcessList($sName)
    If @error Then Return ""
    Local $aMatches[UBound($aPList) ]
    $aMatches[0] = $aPList[0][0]
    For $i = 1 To $aPList[0][0]
        $aMatches[$i] = $aPList[$i][1]
    Next
    Return $aMatches
EndFunc   ;==>_ProcessGetPid
thx but i made easy one have alook ^^

#Include <WinAPI.au3>
$txt=_WinAPI_FindExecutable($file)
$n=StringInStr($txt,"\",2,-1)
$txt=StringTrimLeft($txt,$n)
ProcessClose($txt)
Link to comment
Share on other sites

Oh.., heres another way ^^;

Script :

#Include <WinAPI.Au3>
#Include <String.Au3>

Func _FileDelete ($iFile, $iClose = True)
$Process = _WinAPI_FindExecutable ($iFile)
$Process = _StringReverse ($Process)
$Process = StringSplit ($Process, '\')
$Process = _StringReverse ($Process['1'])
If $iClose = True Then 
If ProcessExists ($Process) Then ProcessClose ($Prcoess)
EndIf 
FileDelete ($iFile)
EndFunc

- John

Latest Projects :- New & Improved TCP Chat

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...