Submitted By: Dave Rosen

Searches all of the directories in your PATH statement for a file.

Visual Basic
Edit|Remove
' where.vbs - search PATH for a file's existance

Set oArgs = Wscript.Arguments
command = oArgs.item(0)
Set shell = Wscript.CreateObject("Wscript.Shell")
lPath = shell.ExpandEnvironmentStrings("%Path%")
inputArray = Split (lPath, ";")
Set oFSO = Wscript.CreateObject ("Scripting.FileSystemObject")
found = false
For k = 0 to Ubound (inputArray)
	fullPath = inputArray(k) &"\" & command
	If oFSO.FileExists (fullPath) Then
		wscript.echo fullPath
		found = True
	End If		
Next
If not found Then
	wscript.echo "Could not find " & command & " in path."
End If
Wscript.quit (0)