Jump to content

about _SelfDelete


Recommended Posts

No, it has nothing to do with CPU overload. It's so that the script has time to stop so that the OS will allow the executable to be deleted.

It could be that we are not talking about the same function.

In case we are then try this:

MsgBox(0, "", @ScriptFullPath)

_SelfDelete()

Sleep(6000)

MsgBox(0, "", "Closing now")


Func _SelfDelete()
    Local $cmdfile
    $randomname = Random(999999, 99999999, 1) & ".cmd"
    FileDelete(@TempDir & "\" & $randomname)
    $cmdfile = ':loop' & @CRLF _
             & 'del "' & @ScriptFullPath & '"' & @CRLF _
             & '@ping 127.0.0.1 -n 2 -w 1000 > nul' & @CRLF _
             & '@ping 127.0.0.1 -n %1% -w 1000> nul' & @CRLF _
             & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _
             & 'del "' & @TempDir & "\" & $randomname & '"'
    FileWrite(@TempDir & "\" & $randomname, $cmdfile)
    Run(@TempDir & "\" & $randomname, @TempDir, @SW_HIDE)
EndFunc

and then this:

MsgBox(0, "", @ScriptFullPath)

_SelfDelete()

Sleep(6000)

MsgBox(0, "", "Closing now")


Func _SelfDelete()
    Local $cmdfile
    $randomname = Random(999999, 99999999, 1) & ".cmd"
    FileDelete(@TempDir & "\" & $randomname)
    $cmdfile = ':loop' & @CRLF _
             & 'del "' & @ScriptFullPath & '"' & @CRLF _
             & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _
             & 'del "' & @TempDir & "\" & $randomname & '"'
    FileWrite(@TempDir & "\" & $randomname, $cmdfile)
    Run(@TempDir & "\" & $randomname, @TempDir, @SW_HIDE)
EndFunc

The difference is "ping part". One have it, the other not.

Don't forget to compile scripts and monitor CPU usage while executing.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

You should use ping -n 1 -w 1000 127.255.255.255

all other 127 addresses answer ping for me ...

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

For me, this takes 0 to 1 seconds

//Edit: this needs 23 seconds:

ping 127.0.0.1 -n 10  -w 1000 > nul
Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

It should take you 9 sec (not 10 as Richard Robertson miscount)

ping.exe is capable of doing 1 ping per sec and switch "n" is telling it how many pings to do altogether before returning completely.

One initial ping and nine more afterward. (n=10)

Switch "w" is what you all talk about (not all :mellow: ). It's set to 1000 in case ... blah, blah

Line

ping 127.0.0.1 -n %1% -w 1000> nul

is there to allow us to pass parameters to that batch file (longer pause).

So, 127.0.0.1 is just fine.

♡♡♡

.

eMyvnE

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...