SAP GUI Install - Current User Profile Environment Variable Help

(imported topic written by SystemAdmin)

Installing SAP GUI and then trying to update the saplogin.ini file after the install. SAP GUI install works like a champ and isn’t a problem.

The problem is updating the saplogonl.ini. It so happens that it is kept in different places depending on the OS.

XP:

c:\documents and settings{currentusername}\application data\sap\common\saplogon.ini

Win7

C:\Users{currentusername}\AppData\Roaming\SAP\Common\saplogon.ini

So we need to figure out if the file exists and update it if it does.

We came up with this:

if (not x64 of operating system) then (exists folder (“c:\documents and settings” & name of current user as string & “\application data\sap\common”) AND not exists file (“c:\documents and settings” & name of current user as string & “\application data\sap\common\saplogon.ini”)) OR (exists file (“c:\documents and settings” & name of current user as string & “\application data\sap\common\saplogon.ini”) AND modification time of file (“c:\documents and settings” & name of current user as string & “\application data\sap\common\saplogon.ini”) < " as time) else (exists folder (“c:\users” & name of current user as string & “\appdata\roaming\sap\common”) AND not exists file (“c:\users” & name of current user as string & “\appdata\roaming\sap\common\saplogon.ini”)) OR (exists file (“c:\users” & name of current user as string & “\appdata\roaming\sap\common\saplogon.ini”) AND modification time of file (“c:\users” & name of current user as string & “\appdata\roaming\sap\common\saplogon.ini”) < “Wed, 07 Sep 2011 11:34:50 -0400” as time)

Which is a whole lotta yuck.

We’d like to use something like this:

if (not x64 of operating system) then (exists folder (value “USERPROFILE” of key “Volatile Environment” of current user key (logged on user) of registry as string & “\application data\sap\common”) AND not exists file (value “USERPROFILE” of key “Volatile Environment” of current user key (logged on user) of registry as string & “\application data\sap\common\saplogon.ini”)) OR (exists file (value “USERPROFILE” of key “Volatile Environment” of current user key (logged on user) of registry as string & “\application data\sap\common\saplogin.ini”) AND modification time of file (value “USERPROFILE” of key “Volatile Environment” of current user key (logged on user) of registry as string & “\application data\sap\common\saplogin.ini”) < “Wed, 07 Sep 2011 11:34:50 -0400” as time) else (exists folder (value “APPDATA” of key “Volatile Environment” of current user key (logged on user) of registry as string & “\sap\common”) AND not exists file (value “APPDATA” of key “Volatile Environment” of current user key (logged on user) of registry as string & “\sap\common\saplogin.ini”)) OR (exists file (value “APPDATA” of key “Volatile Environment” of current user key (logged on user) of registry as string & “\sap\common\saplogin.ini”) AND modification time of file (value “APPDATA” of key “Volatile Environment” of current user key (logged on user) of registry as string & “\sap\common\saplogin.ini”) < “Wed, 07 Sep 2011 11:34:50 -0400” as time)

Which is still yuck, but eliminates having to hard code c:\documents and settings or c:\users. And of course we’de like to not evaluate the relevance - (value “APPDATA” of key “Volatile Environment” of current user key (logged on user) of registry - 6 billions times. But the problem seems to be the relevance - (value “APPDATA” of key “Volatile Environment” of current user key (logged on user) of registry - is not written correctly or simply does not work. But it’s hard to tell since it does not run in the debugger. BTW, most of the relevance was lifted from here - http://forum.bigfix.com/viewtopic.php?id=4228 and http://forum.bigfix.com/viewtopic.php?id=3023.

Any takers on getting this working.

(imported comment written by NoahSalzman)

A quick “parachute” into the thread to answer one tiny bit of the problem… check this option out in the Debugger:

http://forum.bigfix.com/attachment.php?item=457&download=1

(imported comment written by SystemAdmin)

Noah - Excellent. Thank you for pointing that out. I was able to get it working and now I see it’s a resource hog.

How can I prevent myself from having to use the same lines of code

(exists folder (value "APPDATA" of key "Volatile Environment" of current user key (logged on user) of registry as string & ...

repeatedly in a situation like this. This is where my lack of the TEM scripting language kills me. And an evaluation time of 5081.612 ms is going to kill my client computers.

(imported comment written by NoahSalzman)

The evaluation time in the debugger, when using Local Client Evaluator, is not necessarily indicative of the time it will take when actually run on an endpoint.

As far as simplifying the code, how about something like this? Note that I have ripped out the APPDATA chunks to make it easier to read:

if
   not x64 of operating system 
 then
   (
 if
   exists it 
 then
   modification time of it < " as time 
 else
   exists folder "\application data\sap\common\"
   )
   of file "\application data\sap\common\saplogin.ini" 
 else
   (
 if
   exists it 
 then
   modification time of it < "Wed, 07 Sep 2011 11:34:50 -0400" as time 
 else
   exists folder "\sap\common\"
   )
   of file "\sap\common\saplogin.ini"

+Edit: removed needless parentheses +

(imported comment written by SystemAdmin)

Noah,

Trying your version and it works if the file exists, but if the file or folder does not exist, it errors out with “Singular expression refers to nonexistent object.”

The logic flow was:

Does the folder exist?

No - Exit

Yes -> Does the file exist?

No -> Copy the file

Yes -> Is the file the older?

No - Exit

Yes -> Replace the file

Can you explain why this works (Folder and File exist):

exists folder (value “APPDATA” of key “Volatile Environment” of current user key (logged on user) of registry as string & “\sap\common”)

but this does not

exists file (value “APPDATA” of key “Volatile Environment” of current user key (logged on user) of registry as string & “\sap\common\saplogin.ini”)

John