I'm using the Windows Command Processor, (cmd.exe), to scan all the files in a server. My goal is to have a .txt file with name files and where they are located, (for a faster search).

This is my code:

DIR *.* /P /Q /S > C:\Users\aperea01\eng.TXT

DIR *.* /P /Q /S > C:\Users\aperea01\CADUsers.TXT

DIR *.* /P /Q /S > C:\Users\aperea01\eng_restricted.TXT

The batch-file commits its goal, but if I find a folder I have no access, the batch-file stops working. It does write and save the last found files but can't continue.

Is there a way to skip the Access denied error and continue scanning the server?

Thanks in advance.

P, Z and R are some of the mapped network drives in my PC.

  • 2
    You don't think it's the /p switch? Type dir /?. – Noodles Apr 15 at 23:52
  • And what about dir P:\ /Q /S >"%UserProfile%\eng.txt"? It is not necessary to change the drive to get a directory listing. Well, P: changes to current directory on drive P: which must not be the root directory of drive P:. But it looks like you are interested in directory listing of entire drive and so P:\ with /S is enough to get a directory listing of whole drive with owner because of /Q. – Mofi Apr 16 at 6:14
  • Hi @Noodles, /P is not the root cause, even if I remove it from the batch-file, after many many files, when it finds a private folder (personal folder with restricted access), the code save the information and exits the CMD (Windows Command Processor). You were correct on DIR <directory>. – Alejandro Perea Rosales Apr 19 at 1:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.