dazzyreil Posted April 21, 2004 Posted April 21, 2004 how can i get autoit to delete itself (the script) after 1 run ??
Valik Posted April 21, 2004 Posted April 21, 2004 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).
scriptkitty Posted April 21, 2004 Posted April 21, 2004 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.
scriptkitty Posted April 21, 2004 Posted April 21, 2004 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.
trids Posted April 22, 2004 Posted April 22, 2004 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
ezzetabi Posted April 22, 2004 Posted April 22, 2004 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...)
ezzetabi Posted April 22, 2004 Posted April 22, 2004 trids said: 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...
Guest ram1955 Posted May 28, 2004 Posted May 28, 2004 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.
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