Sign in to follow this  
Followers 0
Reaper

FileDelete problem

7 posts in this topic

Ok... Below is the part of the code Im having a problem with...

Im using FileInstall for the 2 7zip files needed.

Then at the end im using FileDelete to remove the 7zip files.

Problem is the filedelete is not removing the 2 files...

Any help would be appreciated.

Func _x64()
    TrayTip('Windows® Defender® definition updates addon maker', '        is compiling files. Please wait ...', 120, 1)
    FileInstall ("C:\aa\7z.dll", @ScriptDir & "\7z.dll")
    FileInstall ("C:\aa\7z.exe", @ScriptDir & "\7z.exe")
    Local $x64_vers, $x64ProdName, $x64_msg, $size_plugin, $line_plugin, $silent_x64, $size_sfx
    $x64_vers = FileGetVersion($download & 'mpas-fex64.exe')
    $x64ProdName = FileGetVersion($download & 'mpas-fex64.exe', 'ProductName')
    $x64_msg = $x64ProdName & " " & $x64_vers & ' for Windows 7 (x64)'
    $silent_x64 = 'mpas-fex64' & '.exe'
    If FileExists($workdir) Then
        DirRemove($workdir, 1)
        DirCreate($workdir)
    Else
    EndIf
    DirCreate($svcpack)
    FileCopy($download & $x64, $workdir & $x64, 9)
    RunWait(@ScriptDir & '\7z a -mx=9 ' & '"..\compresed.7z"' & ' *.exe', $workdir, @SW_HIDE)
    RunWait('CMD /c copy /b Binary64\x64.sfx+Binary64\x64.cfg+compresed.7z ' & '"' & $svcpack & $sfx_x64_plugin & '"', '', @SW_HIDE)
    FileDelete(@ScriptDir & '\compresed.7z')
    FileDelete($workdir & 'mpas-fex64.exe')
    FileMove($svcpack & $sfx_x64_plugin, $Temp1 & $silent_x64, 9)
    DirRemove($svcpack)
    DirRemove($workdir)
    FileDelete($download & 'mpas-fex64.exe')
    DirRemove($download)
    FileCopy($Binary & $Tasks, $Temp & $Tasks, 9)
    FileCopy($Binary & $Install, $Temp2 & $Install, 9)
    FileCopy($Binary & $Reg, $Temp & $Reg, 9)
    RunWait(@ScriptDir & '\7z a -mx=9 ' & '"..\Reapers_Definition_Update_For_Windows_Defender_x64_Windows7_AddOn.WA"', $Temp, @SW_HIDE)
    DirRemove($output)
    FileDelete($Temp & 'Tasks.txt')
    FileDelete($Temp & 'DefUpd.reg')
    FileDelete($Temp2 & 'Install.bat')
    DirRemove($Temp2)
    FileDelete($Temp1 & 'mpas-fex64.exe')
    DirRemove($Temp1)
    DirRemove($Temp3)
    DirRemove($Temp)
    FileMove(@ScriptDir & "\Reapers_Definition_Update_For_Windows_Defender_x64_Windows7_AddOn.WA", @DesktopDir)
    FileDelete(@ScriptDir & '7z.dll')
    FileDelete(@ScriptDir & '7z.exe')
EndFunc   ;==>_x64

Share this post


Link to post
Share on other sites



I suspect the 2 files might be in use at the time you try to delete them.

The easiest thing to try is: sleep for a couple seconds before attempting to delete those files.

If it doesn't work, you'll need to check the process list for 7z and eventually terminate the process then try to delete the files.

Just my 2 cents.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Well i tried the sleep...

No go....

I was watching task manager and 7z.exe closed well before the filedelete....

Still didnt delete the files... :blink:

Share this post


Link to post
Share on other sites

FileDelete(@ScriptDir & '7z.exe')

Should be:

FileDelete(@ScriptDir & '\7z.exe')

----

Is $workdir a global var with trailing backslash?

example:

Global $workdir = @ScriptDir & '\'

or inside the function:

Local $workdir = @ScriptDir & '\'


Make yourself sheep and the wolves will eat you - Benjamin Franklin

Share this post


Link to post
Share on other sites

@ripdad well done :blink:

Didn't spot that error.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Thanks to both of you for your help.

That did it... File gets deleted fine now...

@ripdad

Global $workdir = @ScriptDir & '\workdir\'

Ok... 1 final question if you dont mind...

I would like to have this program check that the computer

it is being run on has internet access..

If it does, just continue as normal.

If it doesn't, pop up a message saying "This program requires internet access, yada yada yada..."

How would I go about doing that?

I really appreciate both of you taking time to help me. Thank you.

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  
Followers 0