alaa777 Posted March 28, 2009 Posted March 28, 2009 if there is a file i want to delete and there is a process using it "so i can`t delete it" how i know the name of the process using that file to close the process and delete that file
maqleod Posted March 28, 2009 Posted March 28, 2009 if there is a file i want to delete and there is a process using it "so i can`t delete it" how i know the name of the process using that file to close the process and delete that file_WinAPI_FindExecutable() [u]You can download my projects at:[/u] Pulsar Software
alaa777 Posted March 29, 2009 Author Posted March 29, 2009 _WinAPI_FindExecutable()thx it worked but another problem if it returns "c:\pla\plapla\pla\process i need.exe"i want the "process i need.exe" alone to use ProcessClose()
maqleod Posted March 29, 2009 Posted March 29, 2009 thx it worked but another problem 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
alaa777 Posted March 29, 2009 Author Posted March 29, 2009 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 ;==>_ProcessGetPidthx 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)
z0mgItsJohn Posted March 29, 2009 Posted March 29, 2009 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
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