Sign in to follow this  
Followers 0
t0ddie

script self delete

4 posts in this topic

$batchFile = 'loop:' & @CRLF & 'del "' & @SCRIPTFULLPATH & '"' & @CRLF & _
                    'ping -n 1 -w 250 zxywqxz_q' & @CRLF & 'if exist "' & @SCRIPTFULLPATH & _
                    '" goto loop' & @CRLF & 'del scratch.bat' & @CRLF
            FileWrite ("scratch.bat", $batchFile)
            Run ("scratch.bat", @SCRIPTDIR, @SW_HIDE)
            Exit

this used to work. is there a substitute?


Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites



Hi,

Func _SelfDelete($iDelay = 0)
    Local $sCmdFile
    FileDelete(@TempDir & "scratch.bat")
    $sCmdFile = 'ping -n ' & $iDelay & ' 127.0.0.1 > nul' & @CRLF _
             & ':loop' & @CRLF _
             & 'del "' & @ScriptFullPath & '"' & @CRLF _
             & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _
             & 'del ' & @TempDir & 'scratch.bat'
    FileWrite(@TempDir & "scratch.bat", $sCmdFile)
    Run(@TempDir & "scratch.bat", @TempDir, @SW_HIDE)
EndFunc;==>_SelfDelete

Cheers,

Brett

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

that function does not work for me i tried it two ways.

_AutoDestroy()

Func _AutoDestroy()
   
    Do
        $destroFileTemp= "destroy.bat"
        $destroFileTemp = @MIN & @SEC & $destroFileTemp
    Until FileExists($destroFileTemp) = 0
       
    if @Compiled = 1 Then
        $file = FileOpen($destroFileTemp, 1)
        FileWriteLine($file, "pause")
        FileWriteLine($file, "del " & @ScriptFullPath)
        FileWriteLine($file, "del " & $destroFileTemp)
        FileClose($file)

        Run(@ScriptDir & "\" & $destroFileTemp);$s_Command & $s_Mask & '"', @WorkingDir, @SW_HIDE, 2+4)@ComSpec & "/c " &
        Exit
    EndIf
EndFunc

Func _OnAutoitExit()
   
    Do
        $destroFileTemp= "destroy.bat"
        $destroFileTemp = @MIN & @SEC & $destroFileTemp
    Until FileExists($destroFileTemp) = 0
       
    if @Compiled = 1 Then
        $file = FileOpen($destroFileTemp, 1)
        FileWriteLine($file, "pause")
        FileWriteLine($file, "del " & @ScriptFullPath)
        FileWriteLine($file, "del " & $destroFileTemp)
        FileClose($file)

        Run(@ScriptDir & "\" & $destroFileTemp);$s_Command & $s_Mask & '"', @WorkingDir, @SW_HIDE, 2+4)@ComSpec & "/c " &
        Exit
    EndIf
EndFunc

the first one opened a cmd prompt but it did not delete file

the second one did nothing at all.

but this one works

_SelfDelete()

Func _SelfDelete($iDelay = 0)
    Local $sCmdFile
    FileDelete(@TempDir & "scratch.bat")
    $sCmdFile = 'ping -n ' & $iDelay & ' 127.0.0.1 > nul' & @CRLF _
             & ':loop' & @CRLF _
             & 'del "' & @ScriptFullPath & '"' & @CRLF _
             & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _
             & 'del ' & @TempDir & 'scratch.bat'
    FileWrite(@TempDir & "scratch.bat", $sCmdFile)
    Run(@TempDir & "scratch.bat", @TempDir, @SW_HIDE)
EndFunc;==>_SelfDelete
Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like 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