0

I had a hard time with Windows 7 OS to where it would think that certain folders are in usage (not allowing folder delete), when in fact they aren't.

After alot of research and trial and error, I was able to use a command that worked well on Windows 7:

rmdir /S /Q "S:\Allied MTRS\Not Scanned\FITTINGS AND FLANGES\RG AR 2686 MOVED FOR AUTO INDEXING"

When I try to run this programmatically via shell command (see code below), it gives me: "File Not Found" message.

So if you try to run it programmatically first, it won't work. Then try to run the same thing, via command line, it works fine. Of course, if you try to run it grammatically again, after that, it will give you "File Not Found" (naturally, since the folder is already deleted). If you want to retry the experiment, you have to try on another folder....

Any ideas?

Sub tryitz()

    Dim s As String
    Dim ReturnCode As Integer

    s = "S:\Allied MTRS\Not Scanned\FITTINGS AND FLANGES\RG AR 2686 MOVED FOR AUTO INDEXING"

    s = "rmdir /S /Q " + Chr(34) + Trim(s) + Chr(34)

    ReturnCode = Shell(s)

End Sub
Heap of Pinto Beans
  • 677
  • 2
  • 12
  • 23

1 Answers1

0

Here is a possible answer, but I am looking for something better. But hey, if not, at least this works, just a little bit more labor in terms of writing a bit of code...

Create a batch file DelFile.Bat, say. The DelFile.Bat is edited by my program (programmatically). I edit it so that it has my desired "rmdir /S /Q? statement.

Then, I run it through shell.

Heap of Pinto Beans
  • 677
  • 2
  • 12
  • 23
  • Thumbs.db may also be contributor to the problem. That is something windows does. You have to delete that hidden file.... There are other posts on this.... – Heap of Pinto Beans Sep 04 '18 at 15:10