Teraterm Log File Name Format

  • I'm using TeraTerm 4.8.5 under Windows 7 (64 bit). Whenever I block the TeraTerm window by moving with the mouse, the hardware flow control becomes active and the log file loses a few characters. I have verified that the computer sending the data really stops the transmission if RTS goes high, still the TeraTerm log loses characters.
  • SET AUTO START LOGGING Tera Term Setup Additional Settings Log Auto start logging SAVE TERA TERM SETTINGS (MANDATORY) After all the settings are made, e.g. Baud, font, Save-To-File name, Auto Start, screen color, etc., save the settings: Tera Term Setup.
  • By default, the resulting log file contains what you type and what Stata produces in response, recorded in a format called Stata Markup and Control Language (SMCL); seePsmcl. The file can be printed or converted to plain text for incorporation into documents you create with your word processor.
  • To save retrieve logs: Select “Log” from File menu and select location of saving file and file name. You may check “Timestamp” option which will add timestamp on log base on PC’s clock information. (Example of timestamp format on log: Wed Feb 25 15:). Type in the respective commands described in Appendix.
HomeSwitchboardUnix AdministrationRed HatTCP/IP NetworksNeoliberalismToxic Managers
May the source be with you, but remember the KISS principle ;-)
Skepticism and critical thinking is not panacea, but can help to understand the world better

SET AUTO START LOGGING Tera Term Setup Additional Settings Log Auto start logging SAVE TERA TERM SETTINGS (MANDATORY) After all the settings are made, e.g. Baud, font, Save-To-File name, Auto Start, screen color, etc., save the settings: Tera Term Setup Save Setup.

NewsTelnet ClientsRecommended LinksTeraterm MacrosReference for macrolanguageInvoking Teraterm from command lineHighlights of enhancements in latest versions
Teraterm loggingCygTerm+SSH Password-less SSH loginTTSSHUsing Pageant for authenticationUsage of SCP with Teraterm
GNU Screen Exceed HostExplorerPuttyTelnet protocolTeraterm connect commandLogMeTTTTPMenu
ExpectTipsAdmin Horror StoriesUnix HistoryHumorEtc

Bases on stack overflow article logging - Change log file name of teraterm log you can add timestamp in the long, which is mandatory if you open several terminals with logging.

I would like to change the default log file name of teraterm terminal log. What I would like to do automatically create/append log in a file name like 'loggedinhost-teraterm.log'

I found following ini setting for log file. It also uses strftime to format log filename.

I have modified it to include date.

Is there any way to prefix hostname in logfile name

Fox eg,

Romme ,

I had the same issue, and was able to solve my problem by adding &h like below;

; Default Log file name. You can specify strftime format to here. LogDefaultName=teraterm &h %d %b %y.log ; Default path to save the log file. LogDefaultPath=C:UsersLogs ; Auto start logging with default log file name. LogAutoStart=on

https://ttssh2.osdn.jp/manual/en/menu/setup-additional.html

'Log' tab

View log editor

Specify the editor that is used for display log file

Default log file name(strftime format)

Specify default log file name. It can include a format of strftime.

example:

teraterm-&h-%Y%m%d_%H_%M_%S.log

Log and replay functions

You can save the host data to the file if you use Tera Term logging function.

Log to the file

You can log characters received from the host. Execute the [File] Log command to start logging.

Do in the following commands:

  1. Do [File] Log command.
  2. 'Tera Term: Log' dialog box will be shown.

    Input the saving file name to `File Name:'.
    All host data will be written to the file if you check `Binary' option.
    KANJI, CR and LF codes are converted to host character code, written to the file if you uncheck `Binary' option. However, the escape sequences are not written to the file.
    The host data will append the file if you check `Append' option.
    The host data will overwrite the file if you uncheck `Append' option.

  3. Push OK button, 'Tera Term: Log' icon will be shown. And logging will start.
  4. Push Close or Pause button on the logging dialog box if you finish the logging or temporarily stop. Pause button will change into Start button if you push Pause button, the logging will restart.

To browse log files, which contain escape sequences, it is convenient to use the replay function of Tera Term. To replay a log file.

Replay the log file

Teraterm Official Site

Run Tera Term with command line in the following:

Tera Term analyzes the specified log file and understands the escape sequence datas. If so, the contents of log file will be displayed in Tera Term window as if the characters were received from the host. We call this function 'replay log'.

And also, you can also use 'Host:' on the [File] New connection command.

NEWS CONTENTS

  • 20200412 : logging - Change log file name of teraterm log - Stack Overflow ( Apr 12, 2020 , stackoverflow.com )
  • 20200412 : logging - Change log file name of teraterm log - Stack Overflow ( Apr 12, 2020 , stackoverflow.com )
  • 20141120 : Logging must be per line not per character ( TeraTerm Support Forums )
  • 20141120 : logpause ( logpause, )

Old News ;-)

Top Visited
Switchboard
Latest
Past week
Past month

[Apr 12, 2020] logging - Change log file name of teraterm log - Stack Overflow

Apr 12, 2020 | stackoverflow.com

Change log file name of teraterm logAsk Question Asked 4 years, 8 months ago Active 10 months ago Viewed 5k times

pmverma ,

I would like to change the default log file name of teraterm terminal log. What I would like to do automatically create/append log in a file name like 'loggedinhost-teraterm.log'

I found following ini setting for log file. It also uses strftime to format log filename.

I have modified it to include date.

Is there any way to prefix hostname in logfile name

Fox eg,

Romme ,

I had the same issue, and was able to solve my problem by adding &h like below;

; Default Log file name. You can specify strftime format to here. LogDefaultName=teraterm &h %d %b %y.log ; Default path to save the log file. LogDefaultPath=C:UsersLogs ; Auto start logging with default log file name. LogAutoStart=on

> ,

https://ttssh2.osdn.jp/manual/en/menu/setup-additional.html

'Log' tab

View log editor

Specify the editor that is used for display log file

Default log file name(strftime format)

Specify default log file name. It can include a format of strftime.

example:

teraterm-&h-%Y%m%d_%H_%M_%S.log

[Apr 12, 2020] logging - Change log file name of teraterm log - Stack Overflow

Apr 12, 2020 | stackoverflow.com

Change log file name of teraterm logAsk Question Asked 4 years, 8 months ago Active 10 months ago Viewed 5k times

pmverma ,

[Nov 20, 2014] Logging must be per line not per character

TeraTerm Support Forums

Post subject: Re: TeraTerm Logging must be per line not per character

Mar 07, 2012 5:26 am

Hi:
I have been using TeraTerm for last 3 years now. I am using version 4.69 currently.

I have to always log everything I do while testing the products I works on. So I turn on logging in TeraTerm.

I have one problem with TeraTerm Logging. When I mis type the command on my product and press backspace to cancel it, TeraTerm logs even that in the log file. This confuses me a lot when I go thru the logs.

I think TeraTerm must log only after user has pressed 'Enter' key. This will have clean log file.

Is there anyway TeraTerm logging can be per line.. rather than per character?

Appreciate your help as this is very important issue for me.

Trevor

Guru

Teraterm Log File Name Format Template

Joined: Wed Jul 26, 2006 4:47 am
Posts: 423
Location: UK

A lot of us certainly would not want the logging to change like this so if it were implemented it should be a configurable item.

logpause

Causes Tera Term to pause logging.

Received characters are discarded while logging is paused.

Example

reading data from telnet session

yoursprp

Teraterm macro tutorial

Post subject: reading data from telnet session

Jun 04, 2014 12:45 pm

Hi,

My telnet server is having some text which scrolling continuously, how can i copy the text to my local computer. simply how can I read server data in telnet session?

Trevor

Guru

Joined: Wed Jul 26, 2006 4:47 am
Posts: 423
Location: UK

Turn logging on maybe?
Click 'File' -> 'Log'

yoursprp

I got some solution

recvln
while result=1
recvln
filewriteln file inputstr
endwhile

Recommended Links

Google matched content

Softpanorama Recommended

Top articles

Sites

Top articles

Sites

Etc

Society

Groupthink :Two Party System as Polyarchy : Corruption of Regulators :Bureaucracies :Understanding Micromanagers and Control Freaks : Toxic Managers : Harvard Mafia :Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience :Who Rules America :Neoliberalism : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace: Skeptical Finance : John Kenneth Galbraith :Talleyrand :Oscar Wilde :Otto Von Bismarck :Keynes :George Carlin :Skeptics :Propaganda : SE quotes : Language Design and Programming Quotes :Random IT-related quotes : Somerset Maugham :Marcus Aurelius :Kurt Vonnegut :Eric Hoffer :Winston Churchill :Napoleon Bonaparte :Ambrose Bierce : Bernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis :Political Skeptic Bulletin, 2013 :Unemployment Bulletin, 2010 : Vol 23, No.10 (October, 2011) An observation about corporate security departments :Slightly Skeptical Euromaydan Chronicles, June 2014 :Greenspan legacy bulletin, 2008 :Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) :Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 :Inequality Bulletin, 2009 :Financial Humor Bulletin, 2008 :Copyleft Problems Bulletin, 2004 :Financial Humor Bulletin, 2011 :Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult :Political Skeptic Bulletin, 2011 :Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering :Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds :Larry Wall :John K. Ousterhout : CTSS : Multix OSUnix History : Unix shell history :VI editor :History of pipes concept :Solaris : MS DOS : Programming Languages History :PL/1 : Simula 67 :C :History of GCC development : Scripting Languages :Perl history :OS History : Mail :DNS : SSH : CPU Instruction Sets :SPARC systems 1987-2006 :Norton Commander :Norton Utilities :Norton Ghost :Frontpage history :Malware Defense History :GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 :The Mythical Man-Month : How to Solve It by George Polya :The Art of Computer Programming :The Elements of Programming Style :The Unix Hater’s Handbook :The Jargon file :The True Believer :Programming Pearls :The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society :Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story :The Cuckoo's Egg :IT Slang : C++ Humor : ARE YOU A BBS ADDICT? :The Perl Purity Test :Object oriented programmers of all nations : Financial Humor :Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor :Goldman Sachs related humor :Greenspan humor : C Humor :Scripting Humor :Real Programmers Humor :Web Humor : GPL-related Humor : OFM Humor :Politically Incorrect Humor :IDS Humor : 'Linux Sucks' Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor :Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor :Networking Humor :Shell Humor :Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 :Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor :Education Humor : IBM Humor : Assembler-related Humor :VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not LeastTechnology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D

Copyright © 1996-2020 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) in the author free time and without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICEThis site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to make a contribution, supporting development of this site and speed up access. In case softpanorama.org is down you can use the at softpanorama.info

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with.We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: April, 12, 2020

-->

All file systems supported by Windows use the concept of files and directories to access data stored on a disk or device. Windows developers working with the Windows APIs for file and device I/O should understand the various rules, conventions, and limitations of names for files and directories.

Data can be accessed from disks, devices, and network shares using file I/O APIs. Files and directories, along with namespaces, are part of the concept of a path, which is a string representation of where to get the data regardless if it's from a disk or a device or a network connection for a specific operation.

Some file systems, such as NTFS, support linked files and directories, which also follow file naming conventions and rules just as a regular file or directory would. For additional information, see Hard Links and Junctions and Reparse Points and File Operations.

For additional information, see the following subsections:

  • File and Directory Names
  • Paths
  • Namespaces

To learn about configuring Windows 10 to support long file paths, see Maximum Path Length Limitation.

File and Directory Names

All file systems follow the same general naming conventions for an individual file: a base file name and an optional extension, separated by a period. However, each file system, such as NTFS, CDFS, exFAT, UDFS, FAT, and FAT32, can have specific and differing rules about the formation of the individual components in the path to a directory or file. Note that a directory is simply a file with a special attribute designating it as a directory, but otherwise must follow all the same naming rules as a regular file. Because the term directory simply refers to a special type of file as far as the file system is concerned, some reference material will use the general term file to encompass both concepts of directories and data files as such. Because of this, unless otherwise specified, any naming or usage rules or examples for a file should also apply to a directory. The term path refers to one or more directories, backslashes, and possibly a volume name. For more information, see the Paths section.

Character count limitations can also be different and can vary depending on the file system and path name prefix format used. This is further complicated by support for backward compatibility mechanisms. For example, the older MS-DOS FAT file system supports a maximum of 8 characters for the base file name and 3 characters for the extension, for a total of 12 characters including the dot separator. This is commonly known as an 8.3 file name. The Windows FAT and NTFS file systems are not limited to 8.3 file names, because they have long file name support, but they still support the 8.3 version of long file names.

Naming Conventions

The following fundamental rules enable applications to create and process valid names for files and directories, regardless of the file system:

  • Use a period to separate the base file name from the extension in the name of a directory or file.

  • Use a backslash () to separate the components of a path. The backslash divides the file name from the path to it, and one directory name from another directory name in a path. You cannot use a backslash in the name for the actual file or directory because it is a reserved character that separates the names into components.

  • Use a backslash as required as part of volume names, for example, the 'C:' in 'C:pathfile' or the 'servershare' in 'serversharepathfile' for Universal Naming Convention (UNC) names. For more information about UNC names, see the Maximum Path Length Limitation section.

  • Do not assume case sensitivity. For example, consider the names OSCAR, Oscar, and oscar to be the same, even though some file systems (such as a POSIX-compliant file system) may consider them as different. Note that NTFS supports POSIX semantics for case sensitivity but this is not the default behavior. For more information, see CreateFile.

  • Volume designators (drive letters) are similarly case-insensitive. For example, 'D:' and 'd:' refer to the same volume.

  • Use any character in the current code page for a name, including Unicode characters and characters in the extended character set (128–255), except for the following:

    • The following reserved characters:

      • < (less than)
      • > (greater than)
      • : (colon)
      • ' (double quote)
      • / (forward slash)
      • (backslash)
      • | (vertical bar or pipe)
      • ? (question mark)
      • * (asterisk)
    • Integer value zero, sometimes referred to as the ASCII NUL character.

    • Characters whose integer representations are in the range from 1 through 31, except for alternate data streams where these characters are allowed. For more information about file streams, see File Streams.

    • Any other character that the target file system does not allow.

  • Use a period as a directory component in a path to represent the current directory, for example '.temp.txt'. For more information, see Paths.

  • Use two consecutive periods (..) as a directory component in a path to represent the parent of the current directory, for example '..temp.txt'. For more information, see Paths.

  • Do not use the following reserved names for the name of a file:

    CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these names followed immediately by an extension; for example, NUL.txt is not recommended. For more information, see Namespaces.

  • Do not end a file or directory name with a space or a period. Although the underlying file system may support such names, the Windows shell and user interface does not. However, it is acceptable to specify a period as the first character of a name. For example, '.temp'.

Short vs. Long Names

A long file name is considered to be any file name that exceeds the short MS-DOS (also called 8.3) style naming convention. When you create a long file name, Windows may also create a short 8.3 form of the name, called the 8.3 alias or short name, and store it on disk also. This 8.3 aliasing can be disabled for performance reasons either systemwide or for a specified volume, depending on the particular file system.

Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: 8.3 aliasing cannot be disabled for specified volumes until Windows 7 and Windows Server 2008 R2.

On many file systems, a file name will contain a tilde (~) within each component of the name that is too long to comply with 8.3 naming rules.

Note

Not all file systems follow the tilde substitution convention, and systems can be configured to disable 8.3 alias generation even if they normally support it. Therefore, do not make the assumption that the 8.3 alias already exists on-disk.

To request 8.3 file names, long file names, or the full path of a file from the system, consider the following options:

  • To get the 8.3 form of a long file name, use the GetShortPathName function.
  • To get the long file name version of a short name, use the GetLongPathName function.
  • To get the full path to a file, use the GetFullPathName function.

On newer file systems, such as NTFS, exFAT, UDFS, and FAT32, Windows stores the long file names on disk in Unicode, which means that the original long file name is always preserved. This is true even if a long file name contains extended characters, regardless of the code page that is active during a disk read or write operation.

Files using long file names can be copied between NTFS file system partitions and Windows FAT file system partitions without losing any file name information. This may not be true for the older MS-DOS FAT and some types of CDFS (CD-ROM) file systems, depending on the actual file name. In this case, the short file name is substituted if possible.

Paths

The path to a specified file consists of one or more components, separated by a special character (a backslash), with each component usually being a directory name or file name, but with some notable exceptions discussed below. It is often critical to the system's interpretation of a path what the beginning, or prefix, of the path looks like. This prefix determines the namespace the path is using, and additionally what special characters are used in which position within the path, including the last character.

If a component of a path is a file name, it must be the last component.

Each component of a path will also be constrained by the maximum length specified for a particular file system. In general, these rules fall into two categories: short and long. Note that directory names are stored by the file system as a special type of file, but naming rules for files also apply to directory names. To summarize, a path is simply the string representation of the hierarchy between all of the directories that exist for a particular file or directory name.

Fully Qualified vs. Relative Paths

For Windows API functions that manipulate files, file names can often be relative to the current directory, while some APIs require a fully qualified path. A file name is relative to the current directory if it does not begin with one of the following:

  • A UNC name of any format, which always start with two backslash characters ('). For more information, see the next section.
  • A disk designator with a backslash, for example 'C:' or 'd:'.
  • A single backslash, for example, 'directory' or 'file.txt'. This is also referred to as an absolute path.

If a file name begins with only a disk designator but not the backslash after the colon, it is interpreted as a relative path to the current directory on the drive with the specified letter. Note that the current directory may or may not be the root directory depending on what it was set to during the most recent 'change directory' operation on that disk. Examples of this format are as follows:

  • 'C:tmp.txt' refers to a file named 'tmp.txt' in the current directory on drive C.
  • 'C:tempdirtmp.txt' refers to a file in a subdirectory to the current directory on drive C.

A path is also said to be relative if it contains 'double-dots'; that is, two periods together in one component of the path. This special specifier is used to denote the directory above the current directory, otherwise known as the 'parent directory'. Examples of this format are as follows:

  • '..tmp.txt' specifies a file named tmp.txt located in the parent of the current directory.
  • '....tmp.txt' specifies a file that is two directories above the current directory.
  • '..tempdirtmp.txt' specifies a file named tmp.txt located in a directory named tempdir that is a peer directory to the current directory.

Relative paths can combine both example types, for example 'C:..tmp.txt'. This is useful because, although the system keeps track of the current drive along with the current directory of that drive, it also keeps track of the current directories in each of the different drive letters (if your system has more than one), regardless of which drive designator is set as the current drive.

Maximum Path Length Limitation

In editions of Windows before Windows 10 version 1607, the maximum length for a path is MAX_PATH, which is defined as 260 characters. In later versions of Windows, changing a registry key or using the Group Policy tool is required to remove the limit. See Maximum Path Length Limitation for full details.

Namespaces

There are two main categories of namespace conventions used in the Windows APIs, commonly referred to as NT namespaces and the Win32 namespaces. The NT namespace was designed to be the lowest level namespace on which other subsystems and namespaces could exist, including the Win32 subsystem and, by extension, the Win32 namespaces. POSIX is another example of a subsystem in Windows that is built on top of the NT namespace. Early versions of Windows also defined several predefined, or reserved, names for certain special devices such as communications (serial and parallel) ports and the default display console as part of what is now called the NT device namespace, and are still supported in current versions of Windows for backward compatibility.

Win32 File Namespaces

The Win32 namespace prefixing and conventions are summarized in this section and the following section, with descriptions of how they are used. Note that these examples are intended for use with the Windows API functions and do not all necessarily work with Windows shell applications such as Windows Explorer. For this reason there is a wider range of possible paths than is usually available from Windows shell applications, and Windows applications that take advantage of this can be developed using these namespace conventions.

For file I/O, the '?' prefix to a path string tells the Windows APIs to disable all string parsing and to send the string that follows it straight to the file system. For example, if the file system supports large paths and file names, you can exceed the MAX_PATH limits that are otherwise enforced by the Windows APIs. For more information about the normal maximum path limitation, see the previous section Maximum Path Length Limitation.

Because it turns off automatic expansion of the path string, the '?' prefix also allows the use of '..' and '.' in the path names, which can be useful if you are attempting to perform operations on a file with these otherwise reserved relative path specifiers as part of the fully qualified path.

Many but not all file I/O APIs support '?'; you should look at the reference topic for each API to be sure.

Note that Unicode APIs should be used to make sure the '?' prefix allows you to exceed the MAX_PATH

Win32 Device Namespaces

The '.' prefix will access the Win32 device namespace instead of the Win32 file namespace. This is how access to physical disks and volumes is accomplished directly, without going through the file system, if the API supports this type of access. You can access many devices other than disks this way (using the CreateFile and DefineDosDevice functions, for example).

For example, if you want to open the system's serial communications port 1, you can use 'COM1' in the call to the CreateFile function. This works because COM1–COM9 are part of the reserved names in the NT namespace, although using the '.' prefix will also work with these device names. By comparison, if you have a 100 port serial expansion board installed and want to open COM56, you cannot open it using 'COM56' because there is no predefined NT namespace for COM56. You will need to open it using '.COM56' because '.' goes directly to the device namespace without attempting to locate a predefined alias.

Another example of using the Win32 device namespace is using the CreateFile function with '.PhysicalDiskX' (where X is a valid integer value) or '.CdRomX'. This allows you to access those devices directly, bypassing the file system. This works because these device names are created by the system as these devices are enumerated, and some drivers will also create other aliases in the system. For example, the device driver that implements the name 'C:' has its own namespace that also happens to be the file system.

APIs that go through the CreateFile function generally work with the '.' prefix because CreateFile is the function used to open both files and devices, depending on the parameters you use.

If you're working with Windows API functions, you should use the '.' prefix to access devices only and not files.

Most APIs won't support '.'; only those that are designed to work with the device namespace will recognize it. Always check the reference topic for each API to be sure.

NT Namespaces

There are also APIs that allow the use of the NT namespace convention, but the Windows Object Manager makes that unnecessary in most cases. To illustrate, it is useful to browse the Windows namespaces in the system object browser using the Windows Sysinternals WinObj tool. When you run this tool, what you see is the NT namespace beginning at the root, or '. The subfolder called 'Global??' is where the Win32 namespace resides. Named device objects reside in the NT namespace within the 'Device' subdirectory. Here you may also find Serial0 and Serial1, the device objects representing the first two COM ports if present on your system. A device object representing a volume would be something like 'HarddiskVolume1', although the numeric suffix may vary. The name 'DR0' under subdirectory 'Harddisk0' is an example of the device object representing a disk, and so on.

To make these device objects accessible by Windows applications, the device drivers create a symbolic link (symlink) in the Win32 namespace, 'Global??', to their respective device objects. For example, COM0 and COM1 under the 'Global??' subdirectory are simply symlinks to Serial0 and Serial1, 'C:' is a symlink to HarddiskVolume1, 'Physicaldrive0' is a symlink to DR0, and so on. Without a symlink, a specified device 'Xxx' will not be available to any Windows application using Win32 namespace conventions as described previously. However, a handle could be opened to that device using any APIs that support the NT namespace absolute path of the format 'DeviceXxx'.

With the addition of multi-user support via Terminal Services and virtual machines, it has further become necessary to virtualize the system-wide root device within the Win32 namespace. This was accomplished by adding the symlink named 'GLOBALROOT' to the Win32 namespace, which you can see in the 'Global??' subdirectory of the WinObj browser tool previously discussed, and can access via the path '?GLOBALROOT'. This prefix ensures that the path following it looks in the true root path of the system object manager and not a session-dependent path.

Related topics