ShawnW Posted October 21, 2010 Share Posted October 21, 2010 I have the need to delete some files while explorer is temporarily closed. I also need to slow certain things down with sleep commands. What I have discovered though is that Sleep means squat when explorer is closed. Shawn Link to comment Share on other sites More sharing options...
Developers Jos Posted October 21, 2010 Developers Share Posted October 21, 2010 ... What I have discovered though is that Sleep means squat when explorer is closed.ShawnCare to explain? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
ShawnW Posted October 21, 2010 Author Share Posted October 21, 2010 Ok here is the part of the code that I'm talking about. All that is really before this is building the arrays of file and directory paths. ; Kill Processes And services Run("sc stop Spooler") ProcessClose("explorer.exe") Sleep(3000) ; Delete the files and directories from the list For $i = 0 To UBound($files)-1 If FileExists($files[$i]) And Not FileDelete($files[$i]) Then Logger("Failed to delete file: " & $files[$i]) Next For $i = 0 To UBound($dirs)-1 If FileExists($dirs[$i]) And Not DirRemove($dirs[$i],1) Then Logger("Failed to remove directory: " & $dirs[$i]) Next Sleep(2000) ; Start Processes Run("explorer.exe") Run("sc start Spooler") Sleep(3000) Without the sleeps it all goes uber fast and certain things get missed because they are in use. But the sleeps don't pause at all. I tried adding a sleep before explorer closes and it works fine. But then the ones after get shot through as if they were not there. Link to comment Share on other sites More sharing options...
Developers Jos Posted October 21, 2010 Developers Share Posted October 21, 2010 (edited) I tried this on my win7/x64 pc and worked fine running from SciTE with F5... ProcessClose("explorer.exe") For $x = 1 to 10 ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : Sleep(2000) = ' & Sleep(2000) & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console Next Explorer was obviously already restarted by the OS before the loop ended. What OS are you testing on? Jos Edited October 21, 2010 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
cembry90 Posted October 21, 2010 Share Posted October 21, 2010 (edited) Ok here is the part of the code that I'm talking about. All that is really before this is building the arrays of file and directory paths. ; Kill Processes And services Run("sc stop Spooler") ProcessClose("explorer.exe") Sleep(3000) ; Delete the files and directories from the list For $i = 0 To UBound($files)-1 If FileExists($files[$i]) And Not FileDelete($files[$i]) Then Logger("Failed to delete file: " & $files[$i]) Next For $i = 0 To UBound($dirs)-1 If FileExists($dirs[$i]) And Not DirRemove($dirs[$i],1) Then Logger("Failed to remove directory: " & $dirs[$i]) Next Sleep(2000) ; Start Processes Run("explorer.exe") Run("sc start Spooler") Sleep(3000) Without the sleeps it all goes uber fast and certain things get missed because they are in use. But the sleeps don't pause at all. I tried adding a sleep before explorer closes and it works fine. But then the ones after get shot through as if they were not there. Try this: ; Kill Processes And services Run("sc stop Spooler") ProcessClose("explorer.exe") While ProcessExists("explorer.exe") Sleep(100) WEnd ; Delete the files and directories from the list For $i = 0 To UBound($files)-1 If FileExists($files[$i]) And Not FileDelete($files[$i]) Then Logger("Failed to delete file: " & $files[$i]) Next For $i = 0 To UBound($dirs)-1 If FileExists($dirs[$i]) And Not DirRemove($dirs[$i],1) Then Logger("Failed to remove directory: " & $dirs[$i]) Next ; Start Processes Run("explorer.exe") Run("sc start Spooler") While Not ProcessExists("explorer.exe") Sleep(100) WEnd Nevermind, I see what you're talking about now. The post above mine should work well for this. Sorry if I caused any confusion. Edited October 21, 2010 by cembry90 AutoIt Stuff: UDFs: {Grow} Link to comment Share on other sites More sharing options...
ShawnW Posted October 21, 2010 Author Share Posted October 21, 2010 XP Pro SP3. Wish it were 7 but my boss is like the least progressive, farthest behind, most scared to death of change IT guy that there ever could be. Link to comment Share on other sites More sharing options...
BinaryBrother Posted October 22, 2010 Share Posted October 22, 2010 http://www.autoitscript.com/forum/index.php?showtopic=77905 SIGNATURE_0X800007D NOT FOUND 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