Page 1 of 1 1
Topic Options
#198437 - 2010-04-23 01:59 AM ReadValue hit & miss
itgaz Offline
Fresh Scripter

Registered: 2009-11-09
Posts: 8
Loc: New Zealand
Sorry posted in wrong version - as below;

Edited by itgaz (2010-04-23 02:03 AM)

Top
#198438 - 2010-04-23 02:02 AM Re: ReadValue hit & miss [Re: itgaz]
itgaz Offline
Fresh Scripter

Registered: 2009-11-09
Posts: 8
Loc: New Zealand
Hello all,

I've written a little script that tells me what Internet browser(s) are installed on a PC and which one is the Default. Here's the simplified version;

 Code:
---------------------------------------------------------------------------
SETCONSOLE("HIDE")
IF Open( 3 , "D:\%USERNAME%.txt" , 5 ) = 0
   WriteLine( 3, @DATE + "," + "%USERNAME%" + "," + "%USERCONTEXT%" + "," + @IPADDRESS0 + "," + @WKSTA + "," + @ProductType 

+ "," + @CSD + ",")
$Explorer = ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer", "Version")
$Firefox = ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox", "CurrentVersion")
$Safari = ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Apple Computer, inc.\Safari", "Version")
$Chrome = ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome", "Version")
$Default = ReadValue("HKEY_CURRENT_USER\Software\Classes\http\shell\open\ddeexec\Application", "")

   If @ERROR = 0

   $x = WriteLine( 3, "Explorer=$Explorer" + "," + "Firefox=$Firefox" + "," + "Safari=$Safari" + "," + "Chrome=$Chrome" + 

"," + "Default=$Default" + @CRLF + @CRLF)
Endif
WriteLine( 3, ",")
---------------------------------------------------------------------------

I added the Prodcut Type and CSD to see if it was a certain version that doesnt work as I dont really need this info, but alas no.


The trouble is I only seem to be getting around half the results back - outputs vary as below;


---------------------------------------------------------------------------
USER,IP,WORKSTATION,Windows XP Professional,Service Pack 3
USER,IP,WORKSTATION,Windows 2000 Professional,Service Pack 4

USERWORX,IP,WORKSTATION,Windows XP Professional,Service Pack 3,Explorer=6.0.2900.5512,Firefox=3.5.9 (en-US),Safari=,Chrome=,Default=Firefox

---------------------------------------------------------------------------


As you can see USERWORX is fine but another user with the same OS & SP (+Image) doesnt.

Anybody have any ideas why some report back and some dont..? It seems to break at the point of ReadValue - but even if the key doesnt exist it shouldnt prevent the rest of the script from running - all machinges should at least be coming back with IE and a Default Browser...

Thanks,

Gaz


Edited by Allen (2010-04-23 06:22 AM)
Edit Reason: added code tags

Top
#198439 - 2010-04-23 06:20 AM Re: ReadValue hit & miss [Re: itgaz]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
After each readvalue line, add ? @serror to see what errors you are getting. Along with this, your if @error=0 is only checking the last readvalue, so it looks like the only time it writes the output is if there is a default value.

Other suggestions...

You are missing an endif.

You should also consider removing the vars in your stings. For example...

$x = WriteLine( 3, "Explorer=" + $Explorer + ",")


Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 382 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.051 seconds in which 0.022 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org