Working directory

In Unix shells, the pwd command outputs a full pathname of the working directory; the equivalent command in DOS and Windows is CD or CHDIR without arguments (whereas in Unix, cd used without arguments takes the user back to their home directory).

[4][3] This can be used to create a temporary batchjob storing the working directory in an environment variable like CD for later use, for example: Alternatively, under Multiuser DOS and DR-DOS 7.02 and higher, various internal and external commands support a parameter /B (for "Batch").

The working directory is also displayed by the $P[nb 2] token of the PROMPT command [6] To keep the prompt short even inside of deep subdirectory structures, the DR-DOS 7.07 COMMAND.COM supports a $W[nb 2] token to display only the deepest subdirectory level.

[3] Under DOS, the absolute paths of the working directories of all logical volumes are internally stored in an array-like data structure called the Current Directory Structure (CDS), which gets dynamically allocated at boot time to hold the necessary number of slots for all logical drives (or as defined by LASTDRIVE).

[7][8][9] This structure imposes a length-limit of 66 characters on the full path of each working directory, and thus implicitly also limits the maximum possible depth of subdirectories.

In the C language, the POSIX function chdir() effects the system call which changes the working directory.