KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Determining which drive is boot on a Windows machine
PRODUCT: 4D | VERSION: 11 | PLATFORM: Win
Published On: September 24, 2010

Depending on how a machine is installed (including the devices connected during installation), the installation drive letter may or may not be the typical C:\ drive.

Here is one approach of finding the actual boot drive letter:

C_TEXT($in;$out;$err)
SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE";"True") ` hide console
LAUNCH EXTERNAL PROCESS("cmd.exe /c echo %SystemDrive%";$in;$out;$err)


The %SystemDrive% environment variable will be returned in the $out local 4D variable.

This information may be useful to 4D developers in order to make sure that when dealing with drive letters on a Windows machine, the actual boot drive is taken into account.

This same strategy can be used for many different Windows settings. Some other useful system environment variables include:

%windir% = the Windows directory; for example: "C:\Winnt" or "C:\Windows"
%tmp% or %temp% = the temp directory; for example: "C:\temp"
%SystemRoot% = the Windows directory; for example: "C:\Winnt" or "C:\Windows"
%USERNAME% = the username of the user logged in
%USERPROFILE% = the profile directory used for the currently logged in user