#201264 - 2010-12-22 08:40 PM
Startup script with getfileversion and readvaule (GPO)
|
xferboy
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
|
|
|
|
#201271 - 2010-12-23 09:05 AM
Re: Startup script with getfileversion and readvaule (GPO)
[Re: ShaneEP]
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
- 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. - 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
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 $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: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, addIf $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!
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 382 anonymous users online.
|
|
|