Jump to content
Sign in to follow this  
experience

Cant get this self delete script to work - please help

Recommended Posts

experience

Hi, i've got a script that i want to self delete once its finished. After i've looked on the forum i've found the script - but i cant get it to work :)

My script is located in:

C:\Documents and Settings\All Users\Start Menu\Programs\Startup\test.exe

but i cant put the path in the following to get it to work

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

Could someone put the path i've quoted and place it in the above script to get it to work ?

Share this post


Link to post
Share on other sites
enaiman

You don't need to add your path anywhere. Once you run your script the macro @ScriptDir points to where your script is located.

From Help:

@ScriptFullPath - Equivalent to @ScriptDir & "\" & @ScriptName

and

@ScriptDir - Directory containing the running script. (Result does not contain a trailing backslash)

... so the script should work without adding anything at all.


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
experience

You don't need to add your path anywhere. Once you run your script the macro @ScriptDir points to where your script is located.

From Help:

and

... so the script should work without adding anything at all.

Hmm well it doesnt do anything for me - i've tried it on a simple piece of code below to open the calc - when its opened the calc the .exe compiled file is still present :) Try it for yourself and let me know where im going wrong

send("{lwin}{r}")
WinWaitActive("Run")
send("{c}{a}{l}{c}{enter}")
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

Share this post


Link to post
Share on other sites
Valuater

in SciTE... Type in

SelfDelete and then press the space bar

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Valuater

You were not "calling" the function

Send("{lwin}{r}")
WinWaitActive("Run")
Send("{c}{a}{l}{c}{enter}")
_SelfDelete()

; Functions
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

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
experience

You were not "calling" the function

Top stuff - thanks for that!

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  

×