speedi Posted May 1, 2008 Posted May 1, 2008 I have a script that contains these 3 commands DirRemove("C:\Testdir", 1) DirCreate("C:\Testdir") exit I do this after copying many files and folders into the \testdir folder (It is a computer speed test) - sometimes the c:\testdir does not get created before the exit. Does the script wait until the dirremove is finished before executing the next command? Thanks!
Developers Jos Posted May 1, 2008 Developers Posted May 1, 2008 I have a script that contains these 3 commandsDirRemove("C:\Testdir", 1)DirCreate("C:\Testdir")exitI do this after copying many files and folders into the \testdir folder (It is a computer speed test) - sometimes the c:\testdir does not get created before the exit.Does the script wait until the dirremove is finished before executing the next command? Thanks!The commands are performed sequencial. Could be the OS isn't done yet, but have you checked the RC and @error returned by the DirCreate() function? 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.
speedi Posted May 1, 2008 Author Posted May 1, 2008 The commands are performed sequencial. Could be the OS isn't done yet, but have you checked the RC and @error returned by the DirCreate() function?What is RC??
Developers Jos Posted May 1, 2008 Developers Posted May 1, 2008 What is RC??Stands for RuturnCode or Return Value. $RC = DirCreate() 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.
speedi Posted May 1, 2008 Author Posted May 1, 2008 Stands for RuturnCode or Return Value. $RC = DirCreate() I tired several ideas I had - did not work I tired this: DirCreate("C:\Testdir") while @error = 1 DirCreate("C:\Testdir") WEnd that didn't work... Can you tell me how to code this part???? Thanks a ton! Jim
martin Posted May 1, 2008 Posted May 1, 2008 (edited) I tired several ideas I had - did not work I tired this: DirCreate("C:\Testdir") while @error = 1 DirCreate("C:\Testdir") WEnd that didn't work... Can you tell me how to code this part???? Thanks a ton! Jim There is no use made of @error in the DirCreate function as far as I can see. If the problem is that DirRemove returns before the folder is actually removed then you could check for its existence. Also, check the return from DirRemove, although from what you say that doesn't appear to be a problem. Local $maxtry = 5, $tries = 0 If DirRemove("C:\Testdir", 1) Then While FileExists("C:\Testdir\..") Sleep(100);might need to add something here to stop getting stuck WEnd While DirCreate("C:\Testdir") = 0 $tries += 1 If $tries = $maxtries Then ExitLoop sleep(200) WEnd If $tries = $maxtries Then MsgBox(0, "ERROR", "Could not create 'C:\Testdir'") Else MsgBox(0, "ERROR", "Cannot remove 'C:\testdir'") EndIf I don't think that would dare to fail. Edited May 1, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
speedi Posted May 1, 2008 Author Posted May 1, 2008 There is no use made of @error in the DirCreate function as far as I can see. If the problem is that DirRemove returns before the folder is actually removed then you could check for its existence. Also, check the return from DirRemove, although from what you say that doesn't appear to be a problem. Local $maxtry = 5, $tries = 0 If DirRemove("C:\Testdir", 1) Then While FileExists("C:\Testdir\..") Sleep(100);might need to add something here to stop getting stuck WEnd While DirCreate("C:\Testdir") = 0 $tries += 1 If $tries = $maxtries Then ExitLoop sleep(200) WEnd If $tries = $maxtries Then MsgBox(0, "ERROR", "Could not create 'C:\Testdir'") Else MsgBox(0, "ERROR", "Cannot remove 'C:\testdir'") EndIf I don't think that would dare to fail. I tried your code and had the same result. the folder isn't created for some reason... I am trying DOS commands now with runwait. If you have any other ideas, please let me know... thanks for your help...
martin Posted May 1, 2008 Posted May 1, 2008 I tried your code and had the same result. the folder isn't created for some reason... I am trying DOS commands now with runwait. If you have any other ideas, please let me know... thanks for your help...Sorry, typing/brain error; "C:\Testdir\.." should have been "C:\Testdir\." I find it difficult to believe you need to resort to DOS commands for this. Can you tell me what the output or result is for this Local $maxtry = 5, $tries = 0 If FileExists("C:\Testdir\.") Then If DirRemove("C:\Testdir", 1) = 0 Then MsgBox(0, "ERROR", "Cannot remove 'C:\testdir'") Exit Else MsgBox(0, "Success", "C:\Testdir removed") EndIf EndIf While FileExists("C:\Testdir\.") $tries += 1 If $tries = $maxtry Then MsgBox(0, "ERROR", "C:\Testdir is not being removed") Exit EndIf Sleep(500);might need to add something here to stop getting stuck WEnd $tries = 0 While DirCreate("C:\Testdir") = 0 $tries += 1 If $tries = $maxtry Then MsgBox(0, "ERROR", "Cannot create C:|Testdir") Exit EndIf Sleep(200) WEnd Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
speedi Posted May 1, 2008 Author Posted May 1, 2008 (edited) It is quite simple. I plan to upgrade my notebook with more memory and a larger hard disk so I want to run a speed test before and after. My script is the speed test and the troublesome part is where I copy most but not all files and folders from "My Documents" to a folder called "testdir". My script records the start and end time and displays the elapsed time when finished. Finally, I want to clear the "testdir" folder to cleanup.... I want to use the "dirremove" so I need not worry about system files or read only files interupting a delete all type function.... the number of files is significant.... Then lastly I want the "testdir" established again before I exit the script... That isn't to complicated I believe.... Thanks for taking the time..... Jim Edited May 1, 2008 by speedi
martin Posted May 1, 2008 Posted May 1, 2008 It is quite simple.I plan to upgrade my notebook with more memory and a larger hard disk so I want to run a speed test before and after.My script is the speed test and the troublesome part is where I copy most but not all files and folders from "My Documents" to a folder called "testdir". My script records the start and end time and displays the elapsed time when finished.Finally, I want to clear the "testdir" folder to cleanup.... I want to use the "dirremove" so I need not worry about system files or read only files interupting a delete all type function.... the number of files is significant....Then lastly I want the "testdir" established again before I exit the script...That isn't to complicated I believe....Thanks for taking the time..... JimBut do you have an answer to my post? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
speedi Posted May 1, 2008 Author Posted May 1, 2008 But do you have an answer to my post?If you mean have I tried the change, I am doing it now...
FreeFry Posted May 2, 2008 Posted May 2, 2008 Would not reading and writing a file to the drive be a more 'reliable' test, than creating a folder?
AdmiralAlkex Posted May 2, 2008 Posted May 2, 2008 Would not reading and writing a file to the drive be a more 'reliable' test, than creating a folder?Would not reading and writing thousands of files be enough?? (läs post 10 igen!!) .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
FreeFry Posted May 2, 2008 Posted May 2, 2008 Ow, that's what happens when one scimms through posts. >_> Only read the "record start and end time" part lol.
speedi Posted May 2, 2008 Author Posted May 2, 2008 I copied your code and pasted it.... the messages I had are "testdir removed" then "testdir not being removed" testdir was removed, but as before not created....
speedi Posted May 2, 2008 Author Posted May 2, 2008 FINAL SOLUTION This is the code that is now working: ***************************************** WinClose("PowerDesk -> C:\testdir\*.*","") ; close it so it is not an issue WinWaitClose("PowerDesk -> C:\testdir\*.*","") sleep(30000) DirRemove("C:\testdir",1) While FileExists("C:\testdir") WEnd MsgBox(4096,"" , "C:\testdir is now gone") DirCreate("C:\testdir") MsgBox(4096,"" , "C:\testdir is back!!!") exit ****************************************** NOTE! Powerdesk is a file management program and since it was showing c:\testdir at the point the dirremove was done, I thought it might be part of the problem, so I used the 1st 2 lines of code above to close that window.... Thanks for everyones help!!!
martin Posted May 2, 2008 Posted May 2, 2008 FINAL SOLUTIONThis is the code that is now working:*****************************************WinClose("PowerDesk -> C:\testdir\*.*","") ; close it so it is not an issueWinWaitClose("PowerDesk -> C:\testdir\*.*","") sleep(30000)DirRemove("C:\testdir",1)While FileExists("C:\testdir")WEndMsgBox(4096,"" , "C:\testdir is now gone")DirCreate("C:\testdir")MsgBox(4096,"" , "C:\testdir is back!!!")exit ******************************************NOTE! Powerdesk is a file management program and since it was showing c:\testdir at the point the dirremove was done, I thought it might be part of the problem, so I used the 1st 2 lines of code above to close that window....Thanks for everyones help!!!Well I'm glad you solved it. Might have been a good idea to mention Powerdesk before.It reminds me (unfairly) of a case some years ago when a customer phoned me up and told me to get someone there as fast as possible because the machine he had bought from me had stopped working. I sent an engineer. When the engineer arrived 3 hours later he reported back that the customer had dropped 2 tons of glass onto the machine from a height of about 4 feet above the machine and seriously damaged it. Obviously the customer didn't think that was worth mentioning. (We got his machine back in action in 2 days.) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
speedi Posted May 2, 2008 Author Posted May 2, 2008 Well I'm glad you solved it. Might have been a good idea to mention Powerdesk before.It reminds me (unfairly) of a case some years ago when a customer phoned me up and told me to get someone there as fast as possible because the machine he had bought from me had stopped working. I sent an engineer. When the engineer arrived 3 hours later he reported back that the customer had dropped 2 tons of glass onto the machine from a height of about 4 feet above the machine and seriously damaged it. Obviously the customer didn't think that was worth mentioning. (We got his machine back in action in 2 days.)Well now I am not so sure that Powerdesk was the problem. I ran the routine 10 times without a glitch 8 of the ten....Twice it stopped while doing the dirremove (powerdesk was closed at that time).. Both times when I looked at \testdir with windows explorer, all the files were gone except one (each time the file left was different). The script is still active at this point and when I try to delete the file via windows explorer, it will not allow it saying is is being used by another process (autoit script I think).... all applications are closed before I run this script and I even turn off the wifi internet access. I have one more idea. I didn't think about the "threatfire" security software that is running all the time... I will disable threatfire and try again several times.... I will post my experience.... thanks! actually I am getting tired of fooling with this especially since my objective speed test is accomplished - this part is just cleaning up....
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