Computing.Net > Forums > Programming > VBS access to registry

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

VBS access to registry

Reply to Message Icon

Name: klint
Date: January 25, 2008 at 03:52:11 Pacific
OS: Windows XP SP2
CPU/Ram: Intel
Product: n/a
Comment:

Can someone show me how to write a VBScript that finds the directory of the latest Java Development Kit, using the following algorithm.

Search the Registry for the following key:

HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit

find the value "CurrentVersion", and then append that value (e.g. "1.6") to the above key and look up the new key, e.g.

HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\1.6

then look in there for the value of "JavaHome" and print it to stdout.

If at any time it doesn't find any of the above, just terminate (preferably with a non-zero exit code) without printing anything.

Thanks in advance. (I need this because I've written a batch file that compiles Java source files, and I'm going to give this to people who possibly may not have added javac.exe in the PATH.)



Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: January 25, 2008 at 07:22:54 Pacific
Reply:

It's all right lads, no need for VBScript, I did it all using batch and reg.exe:


@echo off
for %%j in ("HKLM\SOFTWARE\JavaSoft\Java Development Kit") do (
for /f "tokens=2*" %%a in ('reg query %%j /v CurrentVersion 2^>nul') do if %%a==REG_SZ (
for /f "tokens=2*" %%c in ('reg query "%%~j\%%b" /v JavaHome 2^>nul') do if %%c==REG_SZ (
echo %%d
)
)
)


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: VBS access to registry

VB to MYOB www.computing.net/answers/programming/vb-to-myob/4778.html

Accessing to a network www.computing.net/answers/programming/accessing-to-a-network/20239.html

VB connect to vpn www.computing.net/answers/programming/vb-connect-to-vpn/13800.html