kor Posted December 11, 2014 Share Posted December 11, 2014 ConsoleWrite("2 ") Local $sCheck = Run(@ComSpec & " /c icacls " & $sPath & "\" & $aFolders[$i], '', @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) ConsoleWrite("3 ") Local $sResult While 1 $sResult &= StdoutRead($sCheck) If @error Then ExitLoop WEnd ConsoleWrite("4 " & @CR) $iSearch = StringInStr($sResult, $aFolders[$i] & $sCheckPermissions) My code sets permissions on a folder if the result does not match a search string I'm looking for. My problem is that every so often the script gets stuck inside that While loop and I don't know why. It seems to be random and does not happen all the time. Anyone have any suggestions on some ways I can troubleshoot this to try and figure out what is going on inside the while loop when it gets hung? The script just sits there at 25% cpu forever. I have to end the task and start over to get it to work again. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 11, 2014 Moderators Share Posted December 11, 2014 There are things you can do to help your situation. 1. Do you have to run the the program through comspec? 2. Tighten your loop with more than just getting the data. Local $sResult, $sRead, $iLoop While 1 $sRead = StdoutRead($sCheck) If @error Then ExitLoop If $sRead Then $sResult &= $sRead ; keeps your bytes lower in your return string If Not ProcessExists($sCheck) Then Exitloop ; this probably won't work with the comspec $iLoop += 1 If Mod($iLoop, 50) = 0 Then Sleep(10) ; really just a buffer for the cpu WEnd This isn't much help, but some thoughts all the same. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
BrewManNH Posted December 11, 2014 Share Posted December 11, 2014 First you should never use /c and @SW_HIDE in a run command unless you are 100% sure that it's going to work every time, or as close to 100% sure as you can be. There may be error messages you can't see in the command window, and you will never see them if you use those 2. Second, you should try to add more troubleshooting so you can know what's happening inside the While loop, right now it's a black box with no windows and you have no idea what's going on inside of it. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
computergroove Posted December 11, 2014 Share Posted December 11, 2014 $file = FileOpen("C:\MyLogLog.txt", 1) FileWriteLine($file, "Restarted, " & @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN) FileClose($file) This will keep a running log of an event in a txt file. You just need to add a trigger. I use it to make a log of every time my customers servers reboot. Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html 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