Jump to content

Delete File After Use


Recommended Posts

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.

Link to comment
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

Link to comment
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

Link to comment
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...

Link to comment
Share on other sites

  • 1 month later...
Guest ram1955

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...