Reputation: 7541
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
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