Chapters

  1. Introduction
  2. Structure
  3. Packaging
  4. Logging
  5. Configuration
  6. Debugging EXEs
  7. Handling errors
  8. Testing
  9. Documentation
  10. Make
  11. Providing help
  12. Scheduled Tasks
  13. Windows Services
  14. Windows Event Log
  15. Windows Registry
  16. Creating SetUp.exe
  17. Regular Expressions
  18. Acre
  19. GUI
  20. Git

Appendices

  1. Windows environment vars
  2. User commands
  3. aplcores & WS integrity
  4. Development environment
  5. Special characters

Misc

Windows comes with quite a number of environment variables. Those variables are helpful in addressing, say, a particular path without actually using a physical path.

For example, on most PCs, Windows is installed in C:\Windows, but this is by no means guaranteed. It is therefore much better to address this particular folder as ⊣2 ⎕NQ # 'GetEnvironment' 'WINDIR'.

Below some of the environment variables found on a Windows 10 system are listed and explained.

Information

The Dyalog Cookbook is usually referring to Windows 10 which, in most cases, is identical with Windows 8 and 7. The Cookbook is not applicable to unsupported versions of Windows like Vista and earlier.

Notes:

Some consider environment variables an outdated technology. We don't want to get involved in this argument here but enviroment variables will be round for a very long time, and Windows relies on them. (They are also standard under UNIX, including Linux and MacOS.)

AllUserProfile
Defaults to C:\ProgramData: see ProgramData
AppData

Defaults to C:\Users\{yourName}\AppData\Roaming

Use this to store data that is both application and user specific that is supposed to roam [1] with the user. An INI might be an example.

See also LocalAppData

CommonProgramFiles
Defaults to C:\Program Files\Common Files
CommonProgramFiles(x86)
Defaults to C:\Program Files (x86)\Common Files
CommonProgramW6432
Defaults to C:\Program Files\Common Files
ComputerName
The name of the computer
ComSpec
Defaults to C:\WINDOWS\system32\cmd.exe
ErrorLevel
This variable does not necessarily exist. If you execute ⎕OFF 123 in an APL application it will set ErrorLevel to 123.
HomePath
Defaults to \Users\{yourName}
LocalAppData

Defaults to C:\Users\{yourName}\AppData\Local

Use this to store data that is both application and user specific that is not supposed to roam [1] with the user.

A log file might be an example. The reason is that when a user logs in all the data stored in %APPDATA% is copied over. A large log file might take significant time to be copied with very little (or no) benefit.

See also AppData.

LogonServer
Defaults to the name of the computer your are logged on to. In case of your own desktop PC the values of LogonServer and ComputerName will be the same. In a Windows Server Domain however they will differ.
OS
Specifies the Operating System; under Windows 10, Windows_NT
Path
All the folders (separated by semicola) that the operating system should check if the user enters something like my.exe into a console window and my.exe is not found in the current directory.
PathExt
A list of the file extensions the operating system considers executable, for example: .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC.
ProgramData
Defaults to C:\ProgramData. Use this for information that is application-specific and needs write access after installation. For Dyalog, this would be the right place to store the session file, workspaces and user commands.
ProgramFiles
Defaults to C:\Program Files. On a 64-bit version of Windows this is where 64-bit programs are installed. Note however that on a 32-bit version of Windows this points to ProgramFiles(x86).
ProgramFiles(x86)
Defaults to C:\Program Files (x86). This is where 32-bit programs are installed.
ProgramW6432
Defaults to C:\Program Files. On a 64-bit version of Windows this path points to ProgramFiles. On a 32-bit version of Windows it also points to ProgramFiles which in turn points to ProgramFiles(x86).

For details see WOW64 Implementation Detail [3].

PSModulePath
Defaults to C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\. This path is used by Windows Power Shell [2] to locate modules when the user does not specify the full path to a module.
Public
Defaults to C:\Users\Public. It contains folders like Public Documents, Public Music, Public Pictures, Public Videos, … well, you get the picture.
SystemRoot
Specifies the folder in which Windows is installed. Defaults to C:\WINDOWS.
Temp
Points to the folder that holds temporary files and folders. Defaults to C:\Users\{username}\AppData\Local\Temp. See also TMP.
TMP
Points to the folder that holds temporary files and folders. Defaults to C:\Users\{username}\AppData\Local\Temp. Note that the GetTempFileName API function (which is available as FilesAndDirs.GetTempFilename) will first look for the TMP environment variable and only if that does not exist for the TEMP variable.
Username
The username of the user currently logged on. Same as ⎕AN in APL.
UserProfile
Defaults to C:\Users\{username}. That's where everything is saved that belongs to the user currently logged on. Note that this is kept apart from other user's eyes by the operating system.
WinDir
Defaults to the value of %SystemRoot%. Deprecated.