Factfinder Posted September 6, 2013 Share Posted September 6, 2013 (edited) I have tried many different things with DirRemove but could not remove folders with invalid folder names. As an example folders with invalid folder names like the following: C:Name... C:Name... Those folders can't be deleted manually. rd /s/q CName... and rd /s/q CName... can remove them easilly. The question is if there is an autoit script that can do the same, of course without calling cmd to do the job? Edited September 6, 2013 by Factfinder Link to comment Share on other sites More sharing options...
soonyee91 Posted September 7, 2013 Share Posted September 7, 2013 I have tried using DirRemove to delete folder and it works. Post your code here to have a look? Link to comment Share on other sites More sharing options...
Factfinder Posted September 7, 2013 Author Share Posted September 7, 2013 (edited) Yes, my apologies, not a good example. Please try this one: Edit: Removed this part to avoid using it with wrong intention. You should have a dubdirectory under test with a name that consist of spaces and in this directory the folder with periods in the name. You can't delete this folder manually or with DirRevome("c:test",1). But rd /s/q c:test will remove it. Edited September 8, 2013 by Factfinder Link to comment Share on other sites More sharing options...
Factfinder Posted September 7, 2013 Author Share Posted September 7, 2013 Just to add to the above post. After creating the folder if you apply rd /s/q c:test directly withut trying anything wlse, it removes the folder. But if you try to remove the folder manually first (you will get error with explorer) then apply rd /s/q c:test it will return an error that the directory is not empty. Now you need to apply rd /s/q ".c:test" to remove the folder. Link to comment Share on other sites More sharing options...
soonyee91 Posted September 7, 2013 Share Posted September 7, 2013 Try using Runwait function. Remarks from help file: Paths with spaces need to be enclosed in quotation marks. To run DOS commands, try RunWait(@ComSpec & " /c " & "commandName") ; don't forget " " before "/c" Link to comment Share on other sites More sharing options...
Factfinder Posted September 7, 2013 Author Share Posted September 7, 2013 Thank you. But that is not the question: The question is if there is an autoit script that can do the same, of course without calling cmd to do the job? Link to comment Share on other sites More sharing options...
soonyee91 Posted September 7, 2013 Share Posted September 7, 2013 As far as I know, DirRemove can't remove some dir attributes (which make the removal impossible). Based on my knowledge, I think runwait is the best to solve your problem... Link to comment Share on other sites More sharing options...
Factfinder Posted September 7, 2013 Author Share Posted September 7, 2013 I was aware of calling cmd to do the job. Whether you run cmd from the command prompt, in a batch file or in an autoit script the execution of the command depends on CMD and that is not what Im looking for. There should be a fucntion call, I'm not able to build one, to let inclusion of "?" to take care of the folder with invalid folder name. Here is an C++ example : BOOL WINAPI RemoveDirectory( _In_ LPCTSTR lpPathName ); In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "?" to the path. http://msdn.microsoft.com/en-us/library/windows/desktop/aa365488%28v=vs.85%29.aspx Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 7, 2013 Moderators Share Posted September 7, 2013 Factfinder,If all you want to do is prefix the path with "?" then try this: DirRemove["\\?\" & $sPath)M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
BrewManNH Posted September 7, 2013 Share Posted September 7, 2013 I'd want to find out how the heck you're creating folders with names that are invalid to begin with. Either you're doing something terribly wrong, or some software you're using is doing it. Then I'd either stop doing it or deleting the software. Then you can start to worry about deleting these folders and never creating them again. 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...
ripdad Posted September 7, 2013 Share Posted September 7, 2013 You can't delete this folder manually or with DirRevome("c:test",1). I had no problem deleting the folder with: DirRemove("c:\test", 1) "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward Link to comment Share on other sites More sharing options...
BrewManNH Posted September 7, 2013 Share Posted September 7, 2013 You should have a dubdirectory under test with a name that consist of spaces and in this directory the folder with periods in the name. You can't delete this folder manually or with DirRevome("c:test",1). But rd /s/q c:test will remove it. If you can't do it with one tool, why are you objecting to doing it with another? Especially if the first tool is incapable of dealing with such terribly named folders? It's like insisting on using jackhammer to cut tiles when all it does is destroy them, when a tile cutter already exists to do the job correctly. 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...
Factfinder Posted September 7, 2013 Author Share Posted September 7, 2013 Factfinder, If all you want to do is prefix the path with "?" then try this: DirRemove["\\?\" & $sPath) M23 I have already tried that with no success. But thanks for trying. BrewManNH, There is no intention to do any harm to anybody. If I in anyway offended anyone I apologies for misunderstanding. It is not me or a legit software doing it. The malware makers are already creating those folders and the victims need something to deal with it. They do this to make it more difficult for the average users to remove the bad folders. If you need to know which malware currently is doing this I can give you references as there are plenty of examples on the net (a recent example is ZeroAccess rootkit infection, if you wanted you may google it). I showed how you can create such a folder. But the aim is to find something against it (please note that I have already mentioned how to deal with it with cmd command). If a mod finds my post inappropriate or thinks it shows bad guys to harm others, please feel free to edit or remove my post. I believe this forum is a great forum. I have learned a lot from it and autoit has the potentiality to bypass CMD. I think I might eventually create the right DllCall function to do it, but for the gurus over here that is a lot easier. It looks an extended DirRemove would be a great addition to the function. Thanks to all who cared to reply. Link to comment Share on other sites More sharing options...
martin Posted September 8, 2013 Share Posted September 8, 2013 Why no it use the windows api RemoveDirectory as done in the C example you showed earlier? 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. Link to comment Share on other sites More sharing options...
TheSaint Posted September 8, 2013 Share Posted September 8, 2013 (edited) There was a discussion earlier, somewhere on this forum, that talked a little about a relevant element to this, and was linked to here. If you read through, you will see it discusses the ? prefix Edited September 8, 2013 by TheSaint Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
Starg Posted September 8, 2013 Share Posted September 8, 2013 (edited) Try this:DirRemove(FileGetShortName("\\?\" & $sPath), 1)But why slow? Edited September 8, 2013 by Starg Link to comment Share on other sites More sharing options...
Solution Factfinder Posted September 8, 2013 Author Solution Share Posted September 8, 2013 Strag, I had already tried that. Thanks anyway. Thanks to martin and TheSaint. I think I know how I should do this. Thanks anyone for help. I think I can do this on my own when I get some time. So no need for assistance any more. 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