AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Is there a self-destruct command?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Tezuka
Guest





PostPosted: Thu Oct 22, 2009 5:33 pm    Post subject: Is there a self-destruct command? Reply with quote

I want to be able to send a Hotkey to a friend for him to borrow, but only as a temporary thing. Is there a way for the hotkey to delete itself in a certain time limit after activation?
Back to top
Guest






PostPosted: Thu Oct 22, 2009 5:54 pm    Post subject: Reply with quote

Sure - FileDelete the ahk file and use the ExitApp command.
Back to top
lollorosso
Guest





PostPosted: Thu Oct 22, 2009 6:51 pm    Post subject: Reply with quote

Suspicious.
Back to top
StreetRider@Large
Guest





PostPosted: Thu Oct 22, 2009 7:15 pm    Post subject: Re: Is there a self-destruct command? Reply with quote

Tezuka wrote:
I want to be able to send a Hotkey to a friend for him to borrow, but only as a temporary thing. Is there a way for the hotkey to delete itself in a certain time limit after activation?


Simple and effective..


Code:

IF A_Yday >= 295
   FileDelete, %A_ScriptFullPath%



Today is the 295 day of the year. Just set the number to a short period in the future. Put this code at the start of your code and it will check the current day of the year and delete the file if the day is equal or greater then your "trip" date.
Back to top
Tezuka
Guest





PostPosted: Thu Oct 22, 2009 8:15 pm    Post subject: Reply with quote

Code:


IF A_Yday >= 295
   FileDelete, %A_ScriptFullPath%



Ok so what this does is, if I run the AHK for this code, it will dete the AHK. But the EXE for this does nothing. What would I put for the directory if i wanted to delete the EXE upon activation of the EXE?
Back to top
Tezuka
Guest





PostPosted: Thu Oct 22, 2009 8:20 pm    Post subject: Reply with quote

I mean 'cuz I'll just be sending the EXE to my buddy. And I'd want that to delete after a certain time period.
Back to top
MasterFocus



Joined: 08 Apr 2009
Posts: 882
Location: Rio de Janeiro - RJ - Brasil

PostPosted: Thu Oct 22, 2009 11:07 pm    Post subject: Reply with quote

Use cmd (Comspec).
_________________
Antonio França
aka MasterFocus aka Tunis
+ My AHK stuff: ~MasterFocus
+ AHK @ irc.freenode.net: #ahk
Contact: PM only !
Back to top
View user's profile Send private message
[VxE]



Joined: 07 Oct 2006
Posts: 2342

PostPosted: Fri Oct 23, 2009 8:46 am    Post subject: Reply with quote

Code:
OnExit: ; subroutine called when this script is ready to exit.
If A_Now > 20091225000000 ; e.g. sometime after next X-mas eve...
; delete this script file (.ahk OR .exe) 3 seconds after it terminates.
   Run %comspec% /c ping -n 3 127.0.0.1>nul & Del "%A_ScriptFullPath%",, HIDE
Exitapp ; exit & close the script

This is how it's done for compiled scripts.
_________________
My Home Thread
Common Answers: [1]. It's in the FAQ [2]. Ternary ( a ? b : c ) guide [3]. Post code inside [code][/code] tags !
Back to top
View user's profile Send private message
nostroke



Joined: 22 Oct 2009
Posts: 93

PostPosted: Fri Oct 23, 2009 9:40 am    Post subject: Reply with quote

i speeded it up
If A_Now > 20

at first i seen it in recycle bin

im new but to delete it and by pass recycle bin
shouldn't it be Shift + Delete
Back to top
View user's profile Send private message
StreetRider@Large
Guest





PostPosted: Fri Oct 23, 2009 1:37 pm    Post subject: Almost there Reply with quote

Quote:
i speeded it up
If A_Now > 20

at first i seen it in recycle bin

im new but to delete it and by pass recycle bin
shouldn't it be Shift + Delete


If you use >20 it will always go off. As , this is much lower then any date shown by A_Now (20091225000000)

Try this. Have a FileInstall comand in your script that drops a delete file that is ran on exitapp..

write this into your code.
Code:

ExitApp:
 IF A_Yday >= 295
{
     Run,  Deleter.exe
     ExitApp
}


Create a second little exe that contains only these lines and is named deleter.

Code:


FileAttrib, -r, YourfileName.exe ; Make sure it is not read only.
Filedelete, yourfilename.exe     ; Delete the file



and at the very start of your main script include..
Code:

FileInstall, Deleter.exe, Deleter.exe, 1


That should work for you. You can always have the "Deleter" put into a temp directory or have it as a hidden file. You can tweek this method as much as you want... change locations and names..

The problem you will have is that you must close the program before it can be deleted. So, you start a second program and then kill the first with the second.

FileDelete will not send it to the recycle bin.
Back to top
nostroke



Joined: 22 Oct 2009
Posts: 93

PostPosted: Fri Oct 23, 2009 3:02 pm    Post subject: Reply with quote

i have not tried it but thank

try this code

Code:


SetKeySmack, 1
To=2>Tezuka
4,not saying thank you =1
Send, smack{ENTER} loop 900 }
Filedelete, user.Tezuka
ExitSMACK
Exitapp
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group