itgaz
(Fresh Scripter)
2010-04-23 01:59 AM
ReadValue hit & miss

Sorry posted in wrong version - as below;

itgaz
(Fresh Scripter)
2010-04-23 02:02 AM
Re: ReadValue hit & miss

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


AllenAdministrator
(KiX Supporter)
2010-04-23 06:20 AM
Re: ReadValue hit & miss

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 + ",")