Use 'whereis' command in Windows xp

          'Whereis' command in Windows Vista searches a file in directory included in 'path' environment variable. We can write a batch file that will emulate 'whereis' command as in Windows Vista. Below is a batch script which searches specified file on system drive. This script is slower as it searches entire system drive for file unlike whereis command in Vista and lists every instance of file with it's attributes.

Write 'whereis' emulator:

          Open a notepad, copy and paste the presented whereis.bat code in it. save it as 'whereis.bat'.

whereis.bat Code

@echo off
setlocal
if not "%~0"=="%~0%~1" goto firsttime
:help
echo.
echo help: type 'whereis filename' to run command
echo Don't run whereis on more than one cmd at a time.
echo.
exit /b
:firsttime
if "%~1"=="/?" goto help
set filename=%*
echo %filename%>%temp%\file.txt
cd>%temp%\temp1.txt
cd /d %temp%
for /f "tokens=* " %%i in (file.txt) do set filename=%%~i
cd\
echo.
echo Searching "%filename%" on %systemdrive% drive(System drive).
dir /a:-d /b /s|find /I "%filename%">%temp%\temp2.txt
echo.
cd %temp%
echo.
for /f "tokens=* " %%i in (temp2.txt) do if /I "%filename%"=="%%~nxi" attrib "%%~i"
for /f "tokens=* " %%i in (temp1.txt) do cd /d "%%~i"
del %temp%\temp1.txt
del %temp%\temp2.txt
endlocal

Possible attributes for a file:

A-Archive
H-Hidden
S-System
R-Read only

How To Use:

          Open the folder where you saved the 'whereis.bat', right click on the file and Send To-> Command Prompt Here (We have seen how to add 'Command Prompt Here' option to 'Send To' in previous post. See 'Command Prompt Here'). It will open the command prompt at parent folder.Type

whereis.bat file.ext

Output:

    H c:\file.ext
A   H c:\dir\file.ext

Output Explaination:

          Above output tells that file.exe is present in

  1. C: drive and is hidden.
  2. C:\dir and is archived and hidden.

Useful Modifications:

          You can modify this script to search a file on other drive. Just place the drive letter before cd\ command in bat file. The file also provides help regarding uses if you type whereis /?.

Related Posts:
Leave a comment


1 comment:

Unknown said...

Norton.com/setup | www.norton.com/setup | Norton setup product key, install Norton | activation your product. Norton.com/setup 1844-516-0689 Download & Install Norton antivirus Product Visit activation website www.notroncomsetupactivation.com . Norton Setup Help & Norton Customer support will help you resolve any Malware/virus related issues remotely Call Toll Free Number + 1844-516-0689. For any help regarding Norton Antivirus you can directly call on Norton Antivirus Phone Number + 1844-516-0689.Toll-Free to get instant solution Norton.com/setup+ 1844-516-0689.Call us at ourNorton 360 by Symantec Helpline Number+ 1844-516-0689.to experience the quick and bestNorton.com/setupHelpline Number+ 1844-516-0689. norton.com/setup + 1844-516-0689. www.norton.com/setup l login.norton.com/setup... Norton.com/setup+1844-516-0689 norton.com/setup Norton product key activation, install Norton, Norton, norton.com/setup , Symantec Norton, Norton setup, Norton technical support number, norton.com login, enter Norton product key, Norton antivirus, Norton internet security, Norton security, norton.com/setup sign in, Norton antivirus setup, Norton product key activation, download Norton security, norton.com/setup usa, reinstall Norton Norton.com/setup+1844-516-0689..

Post a Comment