experience Posted June 6, 2007 Share Posted June 6, 2007 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.exebut 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 ? Link to comment Share on other sites More sharing options...
enaiman Posted June 6, 2007 Share Posted June 6, 2007 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 & "\" & @ScriptNameand@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 :) Link to comment Share on other sites More sharing options...
experience Posted June 6, 2007 Author Share Posted June 6, 2007 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 Link to comment Share on other sites More sharing options...
Valuater Posted June 6, 2007 Share Posted June 6, 2007 in SciTE... Type in SelfDelete and then press the space bar 8) Link to comment Share on other sites More sharing options...
Valuater Posted June 7, 2007 Share Posted June 7, 2007 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) Link to comment Share on other sites More sharing options...
experience Posted June 7, 2007 Author Share Posted June 7, 2007 You were not "calling" the functionTop stuff - thanks for that! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now