Yata Posted April 2, 2008 Share Posted April 2, 2008 I need some assistance creating a small script to delete a directory and files under it after a certain program is terminated/no longer running. Is this possible? Could anyone please assist me with this? Link to comment Share on other sites More sharing options...
redsleeves Posted April 2, 2008 Share Posted April 2, 2008 I need some assistance creating a small script to delete a directory and files under it after a certain program is terminated/no longer running. Is this possible? Could anyone please assist me with this? Your script will launch and do nothing while your program's process id exists? When your program's process id no longer exists your script will delete a directory? You could start with this, which is straight out of the AutoIt Help manual: While ProcessExists("YourProcess.exe") WEnd If FileExists("directory\to\delete") Then DirRemove ( "directory\to\delete",1) Probably a better way to do this, as I am fairly confident that my AutoIt skills suck harder than an 18 year old Amish girl. Link to comment Share on other sites More sharing options...
d4rk Posted April 2, 2008 Share Posted April 2, 2008 While ProcessExists("YourProcess.exe") sleep(1000) WEnd If FileExists("directory\to\delete") Then DirRemove ( "directory\to\delete",1) [quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys Link to comment Share on other sites More sharing options...
Yata Posted April 2, 2008 Author Share Posted April 2, 2008 Is there a way for the script to always be running and do the same thing without having to restart the script? Link to comment Share on other sites More sharing options...
Swift Posted April 2, 2008 Share Posted April 2, 2008 (edited) Opt("OnAutoItExit, 1) Func OnAutoItExit() DirRemove(@ScriptDir & "\directory", 1) EndFunc Edited April 2, 2008 by R6V2 Link to comment Share on other sites More sharing options...
crashdemons Posted April 2, 2008 Share Posted April 2, 2008 (edited) I forgot about OnAutoItExit - I was thinking about doing it the hard way - with a temporary instance Didn't test this, but you get the idea... ;Will only work if compiled, since I used ShellEx #Include <Misc.au3> $single=0 If StringInStr(@ScriptName,'_tmp_',1)>0 Then While $single=0 ;dont try to delete the directory until the parent copy is closed $single=_Singleton("MyProgram1", 1) Sleep(100) WEnd If $CmdLineRaw<>"" Then DirRemove($CmdLineRaw,1); remove files and subdirectories EndIf ;do whatever after the dir is removed Else ;do whatever before the dir is removed $single=_Singleton("MyProgram1", 1) $tmpname='_tmp_'&@ScriptName ;temporary application FileCopy(@ScriptFullPath,@TempDir&'\'&$tmpname,0); create a temporary application ShellExecute(@TempDir&'\'&$tmpname,@ScriptDir&'\directory'); run the temp program EndIf Exit Edited April 2, 2008 by crashdemons My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.) 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