Whereis.exe
Ξ July 1st, 2008 | → 1 Comments | ∇ Coding, Geeky, Programming, Software, Technical |
A recent article on one of my favourite blogs was this:
A 90-byte “whereis” program
Sometimes people try too hard.
You can download a C# program to look for a file on your PATH, or you can use a 90-character batch file:
@for %%e in (%PATHEXT%) do @for %%i in (%1%%e)\do @if NOT "%%~$PATH:i"=="" echo %%~$PATH:i
Which is neat – but – I thought I’d knock one up in good ol’ VB6 as a console app for comparison
Here’s the code:
Sub Main()
Dim fso As New FileSystemObject
Dim s As String: Dim sa() As String
Dim n As Integer
sa = Split(Environ("Path"), ";")
For n = 0 To UBound(sa)
s = fso.BuildPath(sa(n), Dir$(fso.BuildPath(sa(n), Command$)))
If fso.FileExists(s) Then
Do
Call fso.GetStandardStream(StdOut).WriteLine(s)
s = fso.BuildPath(sa(n), Dir$)
Loop While fso.FileExists(s)
End If
Next n
End Sub
That’s all you need in a module with a reference to the Microsoft Scripting Runtime. Once built as
where.exe
it’s just a case of using
editbin.exe
editbin /subsystem:console where.exe
I actually think this is more readable than Raymond’s batch file – but then again – I would!
Anyway, here’s some output – just to prove that it works!
C:\>where *ir* C:\WINDOWS\system32\BDir.dll C:\WINDOWS\system32\firewall.cpl C:\WINDOWS\system32\fsquirt.exe C:\WINDOWS\system32\ir32_32.dll C:\WINDOWS\system32\ir41_32.ax C:\WINDOWS\system32\ir41_qc.dll C:\WINDOWS\system32\ir41_qcx.dll C:\WINDOWS\system32\ir50_32.dll C:\WINDOWS\system32\ir50_qc.dll C:\WINDOWS\system32\ir50_qcx.dll C:\WINDOWS\system32\irclass.dll C:\WINDOWS\system32\irftp.exe C:\WINDOWS\system32\irmon.dll C:\WINDOWS\system32\irprops.cpl C:\WINDOWS\system32\itircl.dll C:\WINDOWS\system32\kbdir.dll C:\WINDOWS\system32\msvcirt.dll C:\WINDOWS\system32\MSVCIRT.PDB C:\WINDOWS\system32\MSVCIRTD.DLL C:\WINDOWS\system32\MSVCIRTD.PDB C:\WINDOWS\system32\nddeapir.exe C:\WINDOWS\system32\nvcpluir.dll C:\WINDOWS\system32\redir.exe C:\WINDOWS\system32\scredir.dll C:\WINDOWS\system32\sirenacm.dll C:\WINDOWS\system32\sqlunirl.dll C:\WINDOWS\system32\vdmredir.dll C:\WINDOWS\system32\wshirda.dll C:\WINDOWS\Nircmd.exe C:\WINDOWS\Prairie Wind.bmp C:\WINDOWS\UninstallFirefox.exe C:\Program Files\Windows Resource Kits\Tools\crutredir.dll C:\PROGRA~1\ATT\Graphviz\bin\circo.exe C:\Program Files\Windows PowerShell\v1.0\about_environment_variable.help.txt C:\Program Files\Windows PowerShell\v1.0\about_Execution_environment.help.txt C:\Program Files\Windows PowerShell\v1.0\about_Redirection.help.txt C:\Program Files\QuickTime\QTSystem\Ir41_qc.dll C:\Program Files\QuickTime\QTSystem\Ir41_qcx.dll C:\Program Files\Microsoft Visual Studio\Common\Tools\IROTVIEW.EXE pfirewall.log pfirewall.log.old redir.exe C:\>



on July 3rd, 2008 at 7:45 am
[...] Posted in July 1st, 2008 by in Uncategorized Where.exe PDB C:WINDOWSsystem32MSVCIRTD.DLL C:WINDOWSsystem32MSVCIRTD.PDB [...]