Jump to content
Sign in to follow this  
testbytest

about _SelfDelete

Recommended Posts

testbytest

HI

i used _SelfDelete iS OK

but i can't understand how it work about " 'ping -n ' & $iDelay & '127.0.0.1 > nul' "

It neam ping -n 0127.0.0.1 > nul

but why need this

thanks

Share this post


Link to post
Share on other sites
Richard Robertson

That allows the batch file to wait for a while. It's just an easy way to pause for a period of time.

Share this post


Link to post
Share on other sites
testbytest

That allows the batch file to wait for a while. It's just an easy way to pause for a period of time.

why need this "pause for a period of time "

Share this post


Link to post
Share on other sites
rasim

why need this "pause for a period of time "

For the AutoIt script termination waiting.

Share this post


Link to post
Share on other sites
Richard Robertson

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.

Share this post


Link to post
Share on other sites
trancexx

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

Share this post


Link to post
Share on other sites
ProgAndy

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

Share this post


Link to post
Share on other sites
trancexx

Could someone of you start command prompt and type and execute this:

ping 127.0.0.1 -n 10  -w 1000 > nul

and post return time

...you lost me here


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
Richard Robertson

That code takes 10 seconds to execute.

Share this post


Link to post
Share on other sites
ProgAndy

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

Share this post


Link to post
Share on other sites
trancexx

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

Share this post


Link to post
Share on other sites
Richard Robertson

You also have to remember that ping time can be delayed. Or rather, that pings aren't always instant.

Edited by Richard Robertson

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  

×