Page 1 of 1 1
Topic Options
#201264 - 2010-12-22 08:40 PM Startup script with getfileversion and readvaule (GPO)
xferboy Offline
Just in Town

Registered: 2007-05-14
Posts: 1
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

Top
#201266 - 2010-12-22 09:00 PM Re: Startup script with getfileversion and readvaule (GPO) [Re: xferboy]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
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?

Top
#201271 - 2010-12-23 09:05 AM Re: Startup script with getfileversion and readvaule (GPO) [Re: ShaneEP]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
  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.

Top
#201273 - 2010-12-23 12:59 PM Re: Startup script with getfileversion and readvaule (GPO) [Re: Richard H.]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
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
_________________________
Actually I am a Rocket Scientist! \:D

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.057 seconds in which 0.024 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