xferboy
(Just in Town)
2010-12-22 08:40 PM
Startup script with getfileversion and readvaule (GPO)

Hi all,

I'm trying to get a script to do a little install work for me on startup on some machines using the startup script in GPO's.

I'm using the getfileversion and readvalue to see if certain apps need to be updated (slowly working at removing local admin privileges from workstations).

when running in a start up script, these two functions don't seem to return any data. I use these functions in the logon script and they have been working successfully. The script returns that it's running as system (elevated privileges, I would assume) but can't look at file version or registry entries \:\(

any ideas?

thanks

Allan

Code:
IF Open( 1 , "C:\starup.log" , 5 ) = 0
$x = WriteLine( 1 , "entering Startup script " + @TIME + @CRLF )
$x = writeline(1, "running as " + lcase(@userid) + " " + @TIME + @CRLF)
ENDIF
close(1)

$ret = getfileversion("C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe")
$jret=readvalue("HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment","Java6FamilyVersion")

IF Open( 1 , "C:\starup.log" , 5 ) = 0
$x = WriteLine( 1 , "Adobe Version: |" + $ret + "|" + @TIME + @CRLF )
$x = WriteLine( 1 , "Java Version: |" + $jret + "|" + @TIME + @CRLF )
ENDIF
close(1)

result:
entering Startup script 13:27:51
running as system 13:27:51
Adobe Version: ||13:27:51
Java Version: ||13:27:51


ShaneEP
(MM club member)
2010-12-22 09:00 PM
Re: Startup script with getfileversion and readvaule (GPO)

Off hand, I don't see anything wrong code wise. I would recommend a couple of changes, but nothing that should be causing your issue.

I'd assume it has something to do with the environment being used when the script runs. If you try to run this script manually after login, it works as expected?


Richard H.Administrator
(KiX Supporter)
2010-12-23 09:05 AM
Re: Startup script with getfileversion and readvaule (GPO)

  1. Don't assume that functions will work.
    Check @ERROR and handle any exceptions. At the very least when you are having unexpected results you should display the value of @ERROR and @SERROR after function calls, it will assist you greatly.
  2. Is the machine that the script failing on a 64-bit version of Windows? If it is then check out the SetOption() function and the information on folder/registry redirection.


Glenn BarnasAdministrator
(KiX Supporter)
2010-12-23 12:59 PM
Re: Startup script with getfileversion and readvaule (GPO)

BTW - the info on 64-bit file paths is in the manual, but info on 64-bit registry paths is in the README.TXT file.

Using
 Quote:
$ret = getfileversion("C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe")
is not good, especially as 64-bit systems begin to proliferate. Use %PROGRAMFILES% or %ProgramFiles(x86)% (or check both locations).

Adding the following after the function calls will help you identify what's happening when things don't work:
 Code:
If @ERROR  ; function returned an error
  If Not $Ret
    $Ret = @SERROR
  Else
    $E1 = @SERROR
  EndIf
EndIf
Then, when you write each value to the file, after each writeline, add
 Code:
If $E1
  $x = WriteLine( 1 , "Adobe ERROR:" + $E1 + @CRLF )
EndIf
Of course, you'll need to slightly modify each of these examples to either fill $Ret and $E1 or $JRet and $E2 to represent each query.

There's an fMsg() UDF on my web site's Resources/Kix UDF Lib page that will output messages with timestamps, and also ignore messages unless $DEBUG (a global var) is set. You can optionally specify the debug level, so at level 1, only some messages print, when $DEBUG is 2, more messages print, etc. Setting $DEBUG=0 in your code turns off all debugging messages.

Glenn