Script to search for file and return folder

Microsoft Internet explorer 6 resource k...
December 14, 2010 at 05:13:17
Specs: Windows 2000
I need a script that will search for javaw.exe in subfolder of %programfiles%\Java\ and return the path of the version folder. eg. C:\Program Files\Java\jre1.5.0_17\bin\javaw.exe and return C:\Program Files\Java\jre1.5.0_17.

Either that or use reg query "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment" /s and return the value for javahome = C:\Program Files\Java\jre1.5.0_17.

Any ideas?


See More: Script to search for file and return folder

Report •


#1
January 10, 2011 at 15:15:50
Check this out..
@echo off
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment" /s | findstr /i "Javahome" >%temp%\jv.txt
for /f "tokens=1,2,3,4,5,6 delims=\" %%a in (%temp%\jv.txt) do echo Java version = %%d
for /f "tokens=1,2,* delims= " %%a in (%temp%\jv.txt) do echo Java version = %%c

Subhash Chandra.


Report •

#2
January 10, 2011 at 18:21:17
@ECHO OFF

PUSHD "%programfiles%\java"
FOR /f "tokens=1-4 delims=\" %%a IN ('DIR /b /s "javaw.exe"') DO ECHO %%a\%%b\%%c\%%d
POPD
PAUSE

Can I put a question here?


Report •

#3
January 11, 2011 at 10:15:33
MAtt, yours was qucik!
anyting wrong with my code ?

Subhash Chandra.
www.s-chandra.co.cc


Report •

Related Solutions

#4
January 11, 2011 at 13:04:31
subhash chandra MAtt, yours was qucik! anyting wrong with my code ?

I can't test your code at the moment (on a lousy Mac), but if it works there shouldn't be a problem. I just don't like using the registry as it involves a lot of unnecessary parsing.

Can I put a question here?


Report •

#5
January 12, 2011 at 15:34:23
agreed

Subhash Chandra.
www.s-chandra.co.cc


Report •


Ask Question