Jump to content

Is there a different sleep method?


ShawnW
 Share

Recommended Posts

  • Developers

... What I have discovered though is that Sleep means squat when explorer is closed.

Shawn

Care 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

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

  • Developers

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 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

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 by cembry90

AutoIt Stuff:

 

UDFs: {Grow}

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...