Sign in to follow this  
Followers 0
dazzyreil

Delete File After Use

9 posts in this topic

how can i get autoit to delete itself (the script)

after 1 run ??


Share this post


Link to post
Share on other sites



Probably have to do something like launch a batch file right before closing and have the batch file turn around and delete the AutoIt script and itself (Batch files can delete themselves).

Share this post


Link to post
Share on other sites

yea, batchfiles work well for that:

FileWriteLine("c:\byebye.bat", 'del "'& @ScriptFullPath & '"')
FileWriteLine("c:\byebye.bat", 'del c:\byebye.bat')
Run("c:\byebye.bat")

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

thx its sounds good :huh2:

ill test i now :):D


Share this post


Link to post
Share on other sites

Aye Larry that would be best. On my machine, the AutoIt file always ends before the batch file starts, and thus doens't interfere, but Maybe I have a fast system.

Anyway coded example for ya.

$x=Stringreplace('loop:#del "scriptfile.exe"#rem delay 50 to keep cpu down#ping -n 1 -w 50 gobbledeegook#If Exist scriptfile.exe Goto loop#del c:\byebye.bat','#',@crlf)
$x=StringReplace($x,"scriptfile.exe",@ScriptFullPath)
FileWriteLine("c:\byebye.bat",$x)
Run("c:\byebye.bat",'',@sw_hide)

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

There's also a file somewhere (an INI file?) where you can list files that must be renamed on the next startup. If you specify NULL (or is it NUL?) as the new name, then the file gets deleted.

Sorry for the sketchy details. It's mostly used to delete/rename files that are in use after a normal boot, but if it's just housekeeping you're after, then it might be an option to explore :D

Share this post


Link to post
Share on other sites

In Win9x it is the autoexec.bat

In WinMe the function is not avaiable

In Win2000/XP is the registry key PendingFileRenameOperations in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager ,

but it is a REG_MULTI_SZ value and since it have double blank entries Autoit cant read it correcly so you can only RESET it removing everything is already there not add the file you want delete. (It is a regread know bug...) :D

Share this post


Link to post
Share on other sites

If you specify NULL (or is it NUL?) as the new name, then the file gets deleted.

No way. If in W2000 you try to rename the file using the registry key I mentioned to NUL it happen that you'll have really a file called NUL in the root folder.

Having a non valid name it will be undeletable and unusable, you'll can only delete it setting the regkey correcly...

Share this post


Link to post
Share on other sites

I use a batch file to copy the Autoit3 script from a network drive to the computer it is running on then run the script within the batch file. After it finishes the batch file deletes the script file.

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