Written by

IT Officer, Cellular Pathology at Calderdale and Huddersfield NHS Foundation Trust
Question Robert Steed · Oct 15

How to get the correct USERPROFILE Windows environment variable in Caché ObjectScript please?

$System.Util.GetEnviron("USERPROFILE") returns "C:\WINDOWS\system32\config\systemprofile". I don't know what that is, but that folder doesn't even exist. The correct value which I need is "C:\Users\robert.steed", as seen via the Windows command line "set" command.

Product version: Caché 2018.1
$ZV: Cache for Windows (x86-64) 2018.1.7 (Build 721U) Fri Mar 18 2022 22:07:35 EDT

Comments

Jeffrey Drumm · Oct 15

What account is Caché running under? You'll need to review Windows Services to find the Caché service controller (I don't remember the exact name). It's probably running under the Local System account; you'll need to change it to log on with your own credentials if you want it to use your account's environment.

0
Robert Steed  Oct 27 to Jeffrey Drumm

Thanks Jeffrey. I thought I had replied to your comment already; anyway it was indeed Local System account.

0
David Hockenbroch · Oct 15

I'm not 100% certain, but I think you could use:

set osuser = ##class(%SYS.ProcessQuery).%OpenId($J).OSUserName
set userprofile = "C:\Users\"_osuser
0
Jeffrey Drumm  Oct 15 to David Hockenbroch

If Cache isn't running under his account, it likely won't have access to that directory. 

0
Robert Steed  Oct 20 to David Hockenbroch

Thanks David. It works!

0