Jonathan
Jonathan

Reputation: 7541

How to find whether a non-command file is available in the system path?

I want to test whether a certain file is in the system PATH. in cmd, I can do it using where.exe my.dll.

How do I do it in PowerShell?

This answer suggests Get-Command, which works only for executables - I want to find DLLs as well.

Upvotes: 1

Views: 45

Answers (2)

mjolinor
mjolinor

Reputation: 68243

gci ($env:Path).split(';') -Filter *.dll

Upvotes: 3

arco444
arco444

Reputation: 22821

You could search the path for it as follows:

$ENV:Path -split ';' | % { if ( test-path "$_\my.dll") { write-host $_ } }

The PATH variable is semi-colon separated, so you can split the string using ; as the delimiter, then loop over each location with the file you're seeking appended. If a location is printed, your file will be on the path.

Upvotes: 0

Related Questions