Jump to content

RunWait do not stop.

Recommended Posts


I have a task that I need to clear terminated users home directory in the company. If the path to the folder have more than 256 characters I use robocopy to delete the folder. My function is this:

Func _RoboCopy_NoAD_Accounts($sFolderToDel)
    $prog = @SystemDir & '\RoboCopy.exe'
    $options = '/s /mir'
    $logg = '/LOG+:LogPath'
    Local $sStr = StringReverse($sFolderToDel)
    $sStr = StringReverse(StringMid($sStr,StringInStr($sStr,'\'),StringLen($sStr)))
    if DirCreate($sStr & 'empty_dir') <> 0 Then
        Local $source = $sStr & 'empty_dir'
$sComputername & '.log /NFL /NDL')
        Return RunWait('"' & $prog & '" "' & $source & '" "' & $sFolderToDel & '" ' & $options, "", @SW_MAXIMIZE) ; & ' ' & $logg & $sComputername & '.log /NFL /NDL')
EndFunc   ;==>_RoboCopy_NoAD_Accounts

and I call it like this:

if DirRemove($aListOfAllHomeFolders[$iIndex][0] & "\" & $aListOfAllhomeFolders[$iIndex][1], 1) <> 1 Then
                    If _RoboCopy_NoAD_Accounts($aListOfAllHomeFolders[$iIndex][0] & "\" & $aListOfAllhomeFolders[$iIndex][1]) <> 2 Then
                        _FileWriteLog($hFile, 'Robo Failed to delete ' & $aListOfAllHomeFolders[$iIndex][0] & "\" & $aListOfAllhomeFolders[$iIndex][1])
                        _FileWriteLog($hFile, 'Robo Succeed to delete ' & $aListOfAllHomeFolders[$iIndex][0] & "\" & $aListOfAllhomeFolders[$iIndex][1])
                        $iTotalSize = $iTotalSize + $iSize
                    _FileWriteLog($hFile, 'Succeed to delete ' & $aListOfAllHomeFolders[$iIndex][0] & "\" & $aListOfAllhomeFolders[$iIndex][1])
                    $iTotalSize = $iTotalSize + $iSize

But if the call to RoboCopy function and it is meet with a Error 5 (Access denied) is does not return it just continue to try to delete.

Yours sincerely


Share this post

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

  • Similar Content

    • DynamicRookie
      By DynamicRookie
      Hey There!
      So, what i need to do is an app that can read text in a image (I.e. a png that has text saying "This is a png" and return the text to a variable)
      I'm pretty much a newbie on AutoIt, my purpose is doing that but i don't know any function that can

      Any help is much appreciated
    • santoshM
      By santoshM
      How can i exit from a procedure in auto
      Func test() if x=o then     return endif endFunc  
    • Valnurat
      By Valnurat
      Small question.
      I trying to find all index in an array with value higher than 7.
      How can that be possible?
    • TrashBoat
      By TrashBoat
      Could someone help me create or give an idea of how to do a incrementing for loop that would do this: https://i.imgur.com/YFUt47H.gifv
      I'm having a hard time figuring it out :S
    • msd1994
      By msd1994
      I have a script that just adds some keyboard shortcuts for things like displaying the current song and artist, moving the window to the side so it won't pop up in my way, and play/pause, next song, previous song (these are the only 3 to still work since they don't need the window handle.)
      In some update recently, Spotify's window class swapped from "[CLASS:SpotifyMainWindow]" to "[CLASS:Chrome_WidgetWin_0]". Using the new class in my controls doesn't seem to work, I've tried getting the window handle from the process handle (_GetHwndFromPID($PID)) but that seems to fail as well.
      Does anybody have some idea of a way I could get this script working again?
      edit: seems like discord has the same window class name, so could be some issue with this? Still not sure of a way to solve the issue though, I added a function to get the handle of the active window and can just use that now, but it was able to find it on its own before on spotify startup or script startup which would be preferred.

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.