----^--->
/\

//\\
//The\
/Sy
stem\
////
Guard
\

In the mount of the LORD it shall be seen. Genesis 22:14

GetTempFile

Booming Or Fuming? | MasterCatalog | ntlib (FREE) | NTCmdLib | MtCmds | Scripts | Almost Free | TheGuardBook | Help

 

Types of
.Mount/\Commands

.CrystalClear | .ExactName | .ExitELn | .GetValue | .ifCondition | .ifELn | .IsPattern | .ListValue | .NetValue | .NowValue | .RedirRapids | .ReliableReporting | .RestoreValue | .SetELn | .ValueEcho

.GetValue
Series

  .GetCD | .GetDate | GetDirSize | GetDirSizeM | GetFree | GetFreeM | GetIPAddr | GetIPGateway | GetIPMask | GetLogDate | GetLogTime | GetLogTimeP | GetMac | GetNic | GetOS | GetRole | GetTempFile | GetTime | GetTimeP

.GetTempFile

Description

  1. Calculates and displays a random temporary file name
  2. Saves the value in #TempFile
  3. Saves the previous value of #TempFile (if it exists) in #Previous_#TempFile
  4. Sets errorlevel based on the result

Syntax

%.GetTempFile%    

Parameters and Switches

#TempFile   the random name of a temporary file
#Previous_#TempFile   the saved value of #TempFile from the previous run, if applicable

Errorlevels and Output Variables

Display to
STDOUT

 

Value of
#TempFile

 

Error
Level

  Description of Result

complete
filespec
of the
temporary
file

 

complete
filespec
of the
temporary
file

 

0

  A temporary file with Read-Write access was obtained

n/a

 

n/a

 

1

  No Read-Write access could be found

Examples, Notes and Instructions

  • #TempFile uses the equivalent "short names" for the file and path whenever possible.
  • The temporary file name is constructed in five parts:
~~   literal prefix, always two "~" characters
%~sn0   Expands to the short file name of the script that is running when .GetTempFile is executed.  If this value is unavailable, the literal characters "%~sn0" will be part of the temporary file name.  This usually occurs because .GetTempFile has been run from a  command prompt.  The file name is still valid with the "%~sn0"  characters in it and can be used normally.
-   literal "-" character, separates the short filename from the "random" number
nnnnnnnn   The "random" part of the file name, loosely based on the current Precise Log Time (see #LogTimeP).  While this is not a truly "random" number, it is random enough to allow multiple simultaneous runs of the same script, on the same machine, using the same temp folder, without conflicts.
.txt   the literal ".txt" extension allows easy viewing and editing of the file with a double-click (as opposed to ".tmp")
  • When retrieving one or more temporary files for use in a script, it is best to execute %.GetTempFile% in the main body of the script and not within any subroutine. This will help to avoid the literal characters "%~sn0" as part of the temporary file name.
  • Output is displayed to STDOUT
  • To suppress console display, use

    %.GetTempFile% %.Quiet%

{errorlevel and output variable(s) will still be available}

.GetValue
Series

  .GetCD | .GetDate | GetDirSize | GetDirSizeM | GetFree | GetFreeM | GetIPAddr | GetIPGateway | GetIPMask | GetLogDate | GetLogTime | GetLogTimeP | GetMac | GetNic | GetOS | GetRole | GetTempFile | GetTime | GetTimeP

Related .Mount/\Commands, #Constants, $Functions, :Procedures

Resource

  Short Description
AppendTempFile   append all output to the file specified in #TempFile
CheckTempFile   Checks to see if #TempFile is on an NTFS drive
ClearTempFile   Clear the contents of the file specified in #TempFile
DeleteTempFile   Delete the file specified in #TempFile
HideTempFile   Hide the file specified in #TempFile
MarkTempFile   Mark the file specified in #TempFile to show that it's in use
ReadTempFile   Display the contents of the file specified in #TempFile
ShowTempFile   Shows, or unhides, the file specified in #TempFile
SortTempFile   Sort the contents of the file specified in #TempFile
TouchTempFile   Touch the file specified in #TempFile to show it's in use
WriteTempFile   Write all output to the file specified in #TempFile

 

K

E

Y

Common Commands INTERNAL External /SWITCH Parameter Help text AddonTool
Mounted Commands .Mount/\Command CmdShorthand #Constant $FUNCTION :Procedure !GuardNote
Operating Systems NT/2K/XP/K3 NT Only NT/2K 2K Only 2K/XP XP Only XP/K3 K3 Only 2K/XP/K3
/\
//\\
//
The\
/Sy
stem\
////
Guard
\
COME ON UP WITH US!
and
Congratulations On Your Decision
to
RISE ABOVE
THE REST!

^
/
!\
/LIB\

TheSystemGuard.com [Revised: 2007-03-29]
Copyright © 1995-2007, JWC
Computer Communications,
All Rights Reserved, Worldwide.
 Disclaimer       Privacy       About Us       More


Communication Is Business!

We Master It With Knowledge!

^
/
.\
/M^C\