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

Possible attributes for a file:

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


    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 setup product key, install Norton | activation your product. 1844-516-0689 Download & Install Norton antivirus Product Visit activation website . 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 1844-516-0689.Call us at ourNorton 360 by Symantec Helpline Number+ experience the quick and Number+ 1844-516-0689. + 1844-516-0689. l Norton product key activation, install Norton, Norton, , Symantec Norton, Norton setup, Norton technical support number, login, enter Norton product key, Norton antivirus, Norton internet security, Norton security, sign in, Norton antivirus setup, Norton product key activation, download Norton security, usa, reinstall Norton

Post a Comment