Search code examples
cmddirmicrosoft-distributed-file-system

need to run DIR command and return true or false if path exists


I have a DFS namespace url and want rom time to time to test from another server that uses those resources is access to namespace is permitted.

Manually from CMD I would do something like dir "\\namespaceURL" and the results will be the files and dirs from that namespace.

I just want to configure an alert and trigger a task when the dir command does not return anything. I am thinking at something like:

If (dir "\\namespaceURL" is ok) echo "available" else echo "not-available"   

Can you guys have a look over this and let me know your thoughts?


Solution

  • if exist should be the way to go, but if you want to use dir, here is the syntax:

    dir "\\namespaceURL" >nul 2>&1 && (echo found) || (echo no access)