Home › Forum › Omnis General Forum › Home User path
Tagged: General Coding
-
Home User path
Posted by Paolo Illing on April 24, 2019 at 2:54 pmGood day,
On a mac, but also in windows, how can I retrieve the path of my home directory such as :Users:illing ?alishakihnh alishakihnh replied 4 months ago 4 Members · 3 Replies -
3 Replies
-
Hi Paolo,
there is a funtion in Omnis Studio called
getenv(NameofEnvoronmentVar)
To retrieve the current user’s home directory under windows it would be
Do getenv(“userprofile”) Returns lcUserProfile
where “userprofile” is the name of the corresponding environemt variable.
The function also works on Mac OS but I don’t know the variable name there.
G… should know.
Cheers
Klaus -
we use this in Omnis Studio v6.0. “homedirectorypath” is a character variable.
For Mac,
; user home path
Do $runapplescript(‘path to home folder from user domain as string’,homedirectorypath) Returns errcode`
Calculate homedirectorypath as replaceall(homedirectorypath,kDq,”)
For Windows:
If isunicode()
Register DLL (“shfolder”,”SHGetFolderPathW”,”CJJJJCN”) Returns lnError
Call DLL (“shfolder”,”SHGetFolderPathW”,0,pnFolderType,0,0,lcString,lnError) Returns lcPath
Else
Register DLL (“shfolder”,”SHGetFolderPathA”,”CJJJJCN”) Returns lnError
Call DLL (“shfolder”,”SHGetFolderPathA”,0,pnFolderType,0,0,lcString,lnError) Returns lcPath
End If
Calculate homedirectorypath as lcPath -
The method for retrieving the path of your home directory may vary depending on the operating system you are using. Here are some examples:
On macOS and Linux, you can use the
echo
command with the tilde (~
) symbol to retrieve the path of your home directory. Open the terminal and type: Flappy Bird</p><p>echo ~ </p><p>
This should output the path of your home directory, such as
/Users/illing
on macOS or/home/illing
on Linux.On Windows, you can use the
%HOMEPATH%
environment variable to retrieve the path of your home directory. Open the Command Prompt and type:</p><p>echo %HOMEPATH%</p><p>
This should output the path of your home directory, such as
\Users\illing
on Windows 10.Alternatively, you can also use the
%USERPROFILE%
environment variable to retrieve the path of your user profile directory, which is typically the same as your home directory. For example, on Windows 10, you can type:</p><p>echo %USERPROFILE%</p><p>
This should output the path of your user profile directory, such as
C:\Users\illing
.
Log in to reply.