Jump to content

Can Folders with invalid names be de;ete with Autoit script?


Go to solution Solved by Factfinder,

Recommended Posts

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 by Factfinder
Link to comment
Share on other sites

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 by Factfinder
Link to comment
Share on other sites

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

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

  • Moderators

Factfinder,

If all you want to do is prefix the path with "?" then try this: :)

DirRemove["\\?\" & $sPath)
M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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

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

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

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

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

userbar.png

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