
Change Terminal Server Session properties, use when installing software on a terminal server.
Syntax
CHANGE USER /options
CHANGE LOGON /options
CHANGE PORT /options
Options:
To change .INI file mapping: (administrator rights required)
CHANGE USER /INSTALL Enable install mode. This command has to be run before
installing any new software on a Terminal Server.
This will create a .ini file for the application
in the TS system directory.
CHANGE USER /EXECUTE Enable execute mode (default)
Run this when an installation is complete.
CHANGE USER /QUERY Display current settings.
To enable or disable terminal session logins:
CHANGE LOGON /QUERY Query current terminal session login mode.
CHANGE LOGON /ENABLE Enable user login from terminal sessions.
CHANGE LOGON /DISABLE Disable user login from terminal sessions.
To list or change COM port mappings for the current session.
This can allow DOS applications to access high numbered ports e.g. COM12
CHANGE PORT portx=porty Map port x to port y.
CHANGE PORT /D portx Delete mapping for port x.
CHANGE PORT /QUERY Display current mapping ports.
How .ini files work:
Installing an application will create a .ini file in the TS system directory.
The first time a user runs the application, the application looks in the home directory for its .ini file. If none is found then Terminal Server will copy the .ini file from the system directory to the users home directory.
Each user will have a unique copy of the application's .ini file in their home directory.
To learn more about what happens when the system is put into install mode run CHANGE USER /?
The CHANGE command replaces CHGLOGON, CHGUSER, and CHGPORT from Citrix Winframe.

Change Directory - Select a Folder (and drive)
Syntax
CD [/D] [drive:][path]
CD [..]
Key
/D : change the current DRIVE in addition to changing folder.
Examples
To change to the parent directory.
C:\Work> CD ..
To change to the grant-parent directory.
C:\Work\backup\January> CD ..\..
To change to the ROOT directory.
C:\Work\backup\January> CD \
To display the current directory in the specified drive.
C:\> CD D:
To display the current drive and directory.
C:\Work> CD
To display the current drive and directory.
C:\Work> ECHO "%CD%"
In a batch file to display the location of the batch script file (%0)
C:\> ECHO "%~dp0"
Moving down the folder tree with a full path reference to the ROOT folder...
C:\windows> CD \windows\java
C:\windows\java>
Moving down the folder tree with a reference RELATIVE to the current folder...
C:\windows> CD java
C:\windows\java>
Moving up and down the folder tree in one command...
C:\windows\java> CD ..\system32
C:\windows\system32>
If Command Extensions are enabled the CD command is enhanced as follows:
1) The current directory string is not CASE sensitive.
So CD C:\wiNdoWs will set the current directory to C:\Windows
2) CD does not treat spaces as delimiters, so it is possible to CD into a subfolder name that contains a space without surrounding the name with quotes.
For example:
cd \My folder
is the same as:
cd "\My folder"
3) An asterisk can be used to complete a folder name
e.g. from C:\
C:> CD pro*
will move to
C:\Program Files
CHDIR is a synonym for CD
Tab Completion
This allows changing current folder by entering part of the path and pressing TAB
C:> CD Prog [PRESS TAB]
Will go to C:\Program Files\
Tab Completion is disabled by default, it has been known to create difficulty when using a batch script to process text files that contain TAB characters.
Tab Completion is turned on by setting the registry value shown below
REGEDIT4
[HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
"CompletionChar"=dword:00000009
Changing the Current drive
simply enter the drive letter followed by a colon
C:> E:
E:>
To change drive and directory at the same time, use CD with the /D switch
C:> cd /D E:\utils
E:\utils\>

Call one batch program from another.
Syntax
CALL [drive:][path]filename [parameters]
CALL :label [parameters]
CALL internal_cmd
Key:
pathname The batch program to run
parameters Any command-line arguments
:label Jump to a label in the current batch script.
internal_cmd Any internal command, first expanding any variables in the argument
CALL a second batch file
The CALL command will launch a new batch file context along with any specified arguments.
When the end of the second batch file is reached (or if EXIT is used), control will return to just after the initial CALL statement.
CALL a subroutine (:label)
The CALL command will pass control to the statement after the label specified along with any specified arguments .
To exit the subroutine specify GOTO:eof this will transfer control to the end of the current subroutine.
Arguments can be passed either as a simple string or using a variable:
CALL MyScript.cmd "1234"
CALL OtherScript.cmd %_MyVariable%
Use a label to CALL a subroutine
A label is defined by a single colon followed by a name. This is the basis of a batch file function.
CALL :s_display_result 123
ECHO Done
GOTO :eof
:s_display_result
ECHO The result is %1
GOTO :eof
At the end of the subroutine, GOTO :eof will return to the position where you used CALL.
Example
@ECHO OFF
SETLOCAL
CALL :s_staff SMITH 100
GOTO s_last_bit
:s_staff
ECHO Name is %1
ECHO Rate is %2
GOTO :eof
:s_last_bit
ECHO The end of the script
Advanced usage : CALLing internal commands
In addition to the above, CALL can also be used to run any internal command (SET, ECHO etc) and also expand any environment variables passed on the same line.
For example
@ECHO off
SETLOCAL
set server1=frodo3
set server2=gandalf4
set server3=ascom5
set server4=last1
::run the Loop for each of the servers
call :loop server1
call :loop server2
call :loop server3
call :loop server4
goto:eof
:loop
set _var=%1
:: Evaluate the server name
CALL SET _result=%%%_var%%%
echo The server name is %_result%
goto :eof
:s_next_bit
:: continue below
:: Note the line shown in bold has three '%' symbols
:: The CALL will expand this to: SET _result=%server1%
Each CALL does one substitution of the variables. (You can also do CALL CALL... for multiple substitutions)
If you CALL an executable or resource kit utility make sure it's available on the machine where the batch will be running, also check you have the latest versions of any resource kit utilities.
If Command Extensions are disabled, the CALL command will not accept batch labels.

Display or modify Access Control Lists (ACLs) for files and folders.
Access Control Lists apply only to files stored on an NTFS formatted drive, each ACL determines which users (or groups of users) can read or edit the file. When a new file is created it normally inherits ACL's from the folder where it was created.
Syntax
CACLS pathname [options]
Options:
/T Search the pathname including all subfolders.
/E Edit ACL (leave existing rights unchanged)
/C Continue on access denied errors.
/G user:permission
Grant access rights, permision can be:
R Read
W Write
C Change (read/write)
F Full control
/R user
Revoke specified user's access rights (only valid with /E).
/P user:permission
Replace access rights, permission can be:
N None
R Read
W Write
C Change (read/write)
F Full control
/D user
Deny access to user.
In all the options above "user" can be a UserName or a Workgroup (either local or global)
You can specify more than one user:permission in a single command. Wildcards can be used to specify multiple files.
If a UserName or WGname includes spaces then it must be surrounded with quotes e.g. "Authenticated Users"
If no options are specified CACLS will display the ACLs for the file(s)
Setting Deny permission (/D) will deny access to a user even if they also belong to a group that grants access.
Limitations
Cacls cannot display or modify the ACL state of files locked in exclusive use.
Cacls cannot set the following permissions: change permissions, take ownership, execute, delete use XCACLS to set any of these.
Using CACLS
The CACLS command does not provide a /Y switch to automatically answer 'Y' to the Y/N prompt. However, you can pipe the 'Y' character into the CACLS command using ECHO, use the following syntax:
ECHO Y| CACLS filename /g username:permission
To edit a file you must have the "Change" ACL (or be the file's owner)
To use the CACLS command and change an ACL requires "FULL Control"
File "Ownership" will always override all ACL's - you always have Full Control over files that you create.
If CACLS is used without the /E switch all existing rights on [pathname] will be replaced, any attempt to use the /E switch to change a [user:permission] that already exists will raise an error. To be sure the CALCS command will work without errors use /E /R to remove ACL rights for the user concerned, then use /E to add the desired rights.
The /T option will only traverse subfolders below the current directory
If no options are specified CACLS will display the current ACLs
e.g. To display the current folder
CACLS .
Display permissions for one file
CACLS MyFile.txt
Display permissions for multiple files
CACLS *.txt
Inherited folder permissions are displayed as:
OI - Object inherit - This folder and files. (no inheritance to subfolders)
CI - Container inherit - This folder and subfolders.
IO - Inherit only - The ACE does not apply to the current file/directory
These can be combined as folllows:
(OI)(CI) This folder, subfolders, and files.
(OI)(CI)(IO) Subfolders and files only.
(CI)(IO) Subfolders only.
(OI) (IO) Files only.
So BUILTIN\Administrators:(OI)(CI)F means that both files and Subdirectories will inherit 'F' (Fullcontrol)
similarly (CI)R means Directories will inherit 'R' (Read folders only = List permission)
To actually change the inheritance of a folder/directory use iCACLS /grant or iCACLs /deny
When cacls is applied to the current folder only there is no inheritance and so no output.
Errors when changing permissions
If a user or group has a permission on a file or folder and you grant a second permission to the same user/group on the same folder, NTFS will sometimes produce the error message "The parameter is incorrect" To fix this (or prevent it happening) revoke the permission first (/e /r) and then reapply (/e /g)
Examples:
Add Read-Only permission to a single file
CACLS myfile.txt /E /G "Power Users":R
Add Full Control permission to a second group of users
CACLS myfile.txt /E /G "FinanceUsers":F
Now revoke the Read permissions from the first group
CACLS myfile.txt /E /R "Power Users"
Now give the first group Full-control:
CACLS myfile.txt /E /G "Power Users":F
Give the Finance group Full Control of a folder and all sub folders
CACLS c:\docs\work /E /T /C /G "FinanceUsers":F

Get domain, browser and PDC info.
Syntax:
BROWSTAT option
Options:
BROWSTAT Dumpnet BROWSTAT dn : Display the transports bound to browser
BROWSTAT GetPdc Transport Domain BROWSTAT gp Transport Domain : List the PDC name (via NetBIOS)
BROWSTAT GetMaster Transport Domain BROWSTAT gm Transport Domain : List the remote Master Browser name(via NetBIOS)
BROWSTAT Getblist Transport BROWSTAT gb Transport : List the backup DNS Servers.
BROWSTAT ListWfw BROWSTAT wfw : WindowsForWorkgroups servers running browser.
BROWSTAT Stats \\ServerName BROWSTAT sts \\ServerName : List all browser statistics
BROWSTAT Status : Display Transport,Primary DNS BROWSTAT sta and Backup DNS servers.
BROWSTAT Status -v domain : Verbose Status Display BROWSTAT sta -v domain include Server OS and active browsers.
BROWSTAT Tickle BROWSTAT Tic : Force remote master to stop.
BROWSTAT Elect BROWSTAT el : Force election on remote domain
BROWSTAT View Transport
BROWSTAT vw Transport
BROWSTAT vw Transport ‹domain›
BROWSTAT vw Transport \\Server
BROWSTAT vw Transport \\‹Server› /DOMAIN ‹DomainToQuery›
The VIEW options can enumerate server services running across a server or domain. Other Browstat features will only work only within a single network subnet. To span subnets/routers across a domain, run browstat via psexec.
In the list displays, the following flags are used:
W = Workstation
NT = Windows NT
S = Server
W95 = Windows95
SQL = SQLServer
WFW = WindowsForWorkgroups
SS = StandardServer
MFPN= MS Netware
PDC = PrimaryDomainController
NV = Novell
BDC = BackupDomainController
XN = Xenix
TS = Time Source
MBC = Member Server
PQ = Print Queue Server
DL = Dial-in Server
AFP = AFP Server
OSF = OSF Server
VMS = VMS Server
PBR = Potential Browser
BBR = Backup Browser,
MBR = Master Browser
DMB = DomainMaster Browser
DFS = Distributed File System
Examples
Display transports:
C:\>browstat dn
List of transports currently bound to the browser
1 \Device\NetBT_Tcpip_{B1AFFCA2-6410-4644-9FE7-BA6C274FD4F3}
List the backup DNS servers for transport #1:
C:\>browstat gb 1
Browser: \\PC00096
Browser: \\PC00082
List Print queues for transport #1:
C:\> BROWSTAT vw 1 |find "PQ"

Edit the Windows boot settings stored in Boot.ini
Syntax BOOTCFG /addsw Add OS load options for an OS entry in boot.ini
BOOTCFG /copy Duplicate the entries for an OS instance.
BOOTCFG /dbg1394 Configure 1394 port debugging
BOOTCFG /debug Edit the debug settings for an OS.
BOOTCFG /default Specify the default OS
BOOTCFG /delete Delete an OS entry [operating systems] section of Boot.ini
BOOTCFG /ems Redirect the EMS console to a remote computer (server only). (Emergency Management Services)
BOOTCFG /list List entries in boot.ini
BOOTCFG /query Display section entries from Boot.ini
BOOTCFG /raw Add OS load options, specified as a string
BOOTCFG /rebuild Totally rebuild boot.ini (use when Windows won't start)
BOOTCFG /rmsw Remove OS load options for an OS
BOOTCFG /timeout Change the OS time-out value.Detailed options for all the above are available from BOOTCFG /? Items in bold are only available from the recovery console
Default identification strings:
OS Load Options = /FastdetectLoad Identifier = Microsoft Windows XP Professional
If you intend to rebuild the boot.ini file, delete it first - boot into the recovery console then:
ATTRIB -H -R -S C:\Boot.ini DEL C:\Boot.ini Bootcfg /Rebuild Fixboot

Manage the Background Intelligent Transfer Service (BITS). The BITS Service can be used to transfer large files from remote hosts. BITS supports throttled and asynchronous transfer of files between machines using idle network bandwidth. This service is used by Windows Update, SUS, SMS and many third party packages.
BITSADMIN is deprecated in Windows 7 and 2008 R2, it is superceeded by the new PowerShell BITS cmdlets.
Syntax
BITSADMIN [/RAWRETURN] [/WRAP | /NOWRAP] command
The following commands are available:
/UTIL /? Print the list of utilities commands /PEERCACHING /? Print the list of commands to manage Peercaching /CACHE /? Print the list of cache management commands /PEERS /? Print the list of peer management commands
/LIST [/ALLUSERS] [/VERBOSE] List the jobs /MONITOR [/ALLUSERS] [/REFRESH sec] Monitor the copy manager /RESET [/ALLUSERS] Delete all jobs in the manager
/TRANSFER job name [type] [/PRIORITY priority] [/ACLFLAGS flags] remote_url local_name Transfer one of more files. [type] may be /DOWNLOAD or /UPLOAD; default is download Multiple URL/file pairs may be specified. Unlike most commands, job name may only be a name and not a GUID.
/CREATE [type] job name Create a job [type] may be /DOWNLOAD, /UPLOAD, or /UPLOAD-REPLY; default is download Unlike most commands, job name may only be a name and not a GUID.
/INFO job [/VERBOSE] Display information about the job
/ADDFILE job remote_url local_name Add a file to the job
/ADDFILESET job textfile Add multiple files to the job Each line of textfile lists a file's remote name and local name, separated by spaces. A line beginning with '#' is treated as a comment. Once the file set is read into memory, the contents are added to the job.
/ADDFILEWITHRANGES job remote_url local_name range_list Like /ADDFILE, but BITS will read only selected byte ranges of the URL. range_list is a comma-delimited series of offset and length pairs. For example,
0:100,2000:100,5000:eof
instructs BITS to read 100 bytes starting at offset zero, 100 bytes starting at offset 2000, and the remainder of the URL starting at offset 5000.
/REPLACEREMOTEPREFIX job old_prefix new_prefix All files whose URL begins with old_prefix are changed to use new_prefix
Note that BITS currently supports HTTP/HTTPS downloads and uploads. It also supports UNC paths and file:// paths as URLS
/LISTFILES job List the files in the job /SUSPEND job Suspend the job /RESUME job Resume the job /CANCEL job Cancel the job /COMPLETE job Complete the job
/GETTYPE job Retrieve the job type /GETACLFLAGS job Retrieve the ACL propagation flags
/SETACLFLAGS job ACL_flags Set the ACL propagation flags for the job O - OWNER G - GROUP D - DACL S - SACL
Examples:
bitsadmin /setaclflags MyJob OGDS bitsadmin /setaclflags MyJob OGD
/GETBYTESTOTAL job Retrieve the size of the job /GETBYTESTRANSFERRED job Retrieve the number of bytes transferred /GETFILESTOTAL job Retrieve the number of files in the job /GETFILESTRANSFERRED job Retrieve the number of files transferred /GETCREATIONTIME job Retrieve the job creation time /GETMODIFICATIONTIME job Retrieve the job modification time /GETCOMPLETIONTIME job Retrieve the job completion time /GETSTATE job Retrieve the job state /GETERROR job Retrieve detailed error information /GETOWNER job Retrieve the job owner /GETDISPLAYNAME job Retrieve the job display name /SETDISPLAYNAME job display_name Set the job display name /GETDESCRIPTION job Retrieve the job description /SETDESCRIPTION job description Set the job description /GETPRIORITY job Retrieve the job priority /SETPRIORITY job priority Set the job priority Priority usage choices: FOREGROUND HIGH NORMAL LOW /GETNOTIFYFLAGS job Retrieve the notify flags /SETNOTIFYFLAGS job notify_flags Set the notify flags /GETNOTIFYINTERFACE job Determines if notify interface is registered /GETMINRETRYDELAY job Retrieve the retry delay in seconds /SETMINRETRYDELAY job retry_delay Set the retry delay in seconds /GETNOPROGRESSTIMEOUT job Retrieve the no progress timeout in seconds /SETNOPROGRESSTIMEOUT job timeout Set the no progress timeout in seconds /GETMAXDOWNLOADTIME job Retrieve the download timeout in seconds /SETMAXDOWNLOADTIME job timeout Set the download timeout in seconds /GETERRORCOUNT job Retrieve an error count for the job
/SETPROXYSETTINGS job usage Set the proxy usage usage choices:
PRECONFIG - Use the owner's IE defaults. AUTODETECT - Force autodetection of proxy. NO_PROXY - Do not use a proxy server. OVERRIDE - Use an explicit proxy list and bypass list. Must be followed by a proxy list and a proxy bypass list. NULL or "" may be used for an empty proxy bypass list.
Examples:
bitsadmin /setproxysettings MyJob PRECONFIG bitsadmin /setproxysettings MyJob AUTODETECT bitsadmin /setproxysettings MyJob NO_PROXY bitsadmin /setproxysettings MyJob OVERRIDE proxy1:80 "local" bitsadmin /setproxysettings MyJob OVERRIDE proxy1,proxy2,proxy3 NULL
/GETPROXYUSAGE job Retrieve the proxy usage setting /GETPROXYLIST job Retrieve the proxy list /GETPROXYBYPASSLIST job Retrieve the proxy bypass list
/TAKEOWNERSHIP job Take ownership of the job
/SETNOTIFYCMDLINE job program_name [program_parameters] Sets a program to execute for notification, and optionally parameters. The program name and parameters can be NULL. IMPORTANT: if parameters are non-NULL, then the program name should be the first parameter.
Examples:
bitsadmin /SetNotifyCmdLine MyJob c:\winnt\system32\notepad.exe NULL bitsadmin /SetNotifyCmdLine MyJob c:\foo.exe "c:\foo.exe parm1 parm2" bitsadmin /SetNotifyCmdLine MyJob NULL NULL
/GETNOTIFYCMDLINE job Return the job's notification command line
/SETCREDENTIALS job target scheme username password Adds credentials to a job. target may be either SERVER or PROXY scheme may be BASIC, DIGEST, NTLM, NEGOTIATE, or PASSPORT.
/REMOVECREDENTIALS job target scheme Removes credentials from a job. /GETCUSTOMHEADERS job Get the Custom HTTP Headers /SETCUSTOMHEADERS job header1 header2 ... Set the Custom HTTP Headers /GETCLIENTCERTIFICATE job Get the job's Client Certificate Information /SETCLIENTCERTIFICATEBYID job store_location store_name hexa-decimal_cert_id Set a client authentication certificate to a job. store_location may be 1(CURRENT_USER), 2(LOCAL_MACHINE), 3(CURRENT_SERVICE), 4(SERVICES), 5(USERS), 6(CURRENT_USER_GROUP_POLICY), 7(LOCAL_MACHINE_GROUP_POLICY) or 8(LOCAL_MACHINE_ENTERPRISE).
/SETCLIENTCERTIFICATEBYNAME job store_location store_name subject_name Set a client authentication certificate to a job. store_location may be 1(CURRENT_USER), 2(LOCAL_MACHINE), 3(CURRENT_SERVICE), 4(SERVICES), 5(USERS), 6(CURRENT_USER_GROUP_POLICY), 7(LOCAL_MACHINE_GROUP_POLICY) or 8(LOCAL_MACHINE_ENTERPRISE).
/REMOVECLIENTCERTIFICATE job Remove the Client Certificate Information from the job
/SETSECURITYFLAGS job value Set the HTTP security flags for URL redirection and checks performed on the server cert. during the transfer. The value is an unsigned integer with the following interpretation for the bits in the binary representation. Enable CRL Check : Set the least significant bit Ignore invalid common name in server certificate : Set the 2nd bit from right Ignore invalid date in server certificate : Set the 3rd bit from right Ignore invalid certificate authority in server certificate : Set the 4th bit from right Ignore invalid usage of certificate : Set the 5th bit from right Redirection policy : Controlled by the 9th-11th bits from right 0,0,0 - Redirects will be automatically allowed. 0,0,1 - Remote name in the IBackgroundCopyFile interface will be updated if a redirect occurs. 0,1,0 - BITS will fail the job if a redirect occurs.
Allow redirection from HTTPS to HTTP : Set the 12th bit from right
/GETSECURITYFLAGS job Report the HTTP security flags for URL redirection and checks performed on the server certificate during the transfer.
/SETVALIDATIONSTATE job file-index true|false starts from 0 Set the content-validation state of the given file within the job.
/GETVALIDATIONSTATE job file-index starts from 0 Report the content-validation state of the given file within the job.
/GETTEMPORARYNAME job file-index file-index starts from 0 Report the temporary filename of the given file within the job.
The following options control peercaching of a particular job:
/SETPEERCACHINGFLAGS job value Sets the flags for the job's peercaching behavior. The value is an unsigned integer with the following interpretation for the bits in the binary representation. Allow the job's data to be downloaded from a peer : Set the least significant bit Allow the job's data to be served to peers : Set the 2nd bit from right
/GETPEERCACHINGFLAGS job Report the flags for the job's peercaching behavior.
The following options are valid for UPLOAD-REPLY jobs only:
/GETREPLYFILENAME job Get the path of the file containing the server reply /SETREPLYFILENAME job path Set the path of the file containing the server reply /GETREPLYPROGRESS job Get the size and progress of the server reply /GETREPLYDATA job Dump the server's reply data in hex format
The following options can be placed before the command: /RAWRETURN Return data more suitable for parsing /WRAP Wrap output around console (default) /NOWRAP Don’t wrap output around console
The /RAWRETURN option strips new line characters and formatting. It is recognized by the /CREATE and /GET* commands.
Commands that take a job parameter will accept either a job name or a job ID GUID inside braces.
BITSADMIN reports an error if a name is ambiguous.
Many commands are only compatible with Microsoft IIS servers (e.g. upload).
BITSADMIN is deprecated in Windows 7 and 2008 R2, it is superceeded by the new PowerShell BITS cmdlets.
Examples
Create a new download job:C:\> Bitsadmin /create /download SS64
Add a file that we want to download to the job and specify a location where the downloaded file will be stored:C:\> Bitsadmin /addfile SS64 http://download.sysinternals.com/files/PSTools.zip c:\PSTools.zipC:\> Bitsadmin /resume SS64
Check if a download job has finished and if so complete the job:C:\> Bitsadmin /info SS64 /verbose | find "STATE: TRANSFERRED"C:\> IF %ERRORLEVEL% EQU 0 bitsadmin /complete SS64

Set up a system partition, repair the boot environment located on the system partition.
SyntaxBCDBOOT source [/l locale] [/s volume-letter][/v] [/m [{OS Loader GUID}]]
Optionssource The location of the Windows directory to use as the source for copying boot-environment files.
/l The locale. default = US English.
/s The volume letter of the system partition. The default is the system partition identified by the firmware.
/v Enable verbose mode
/m By default, merge only global objects. If an OS Loader GUID is specified, merge the given loader object within the system template to produce a bootable entry.
BCDboot may also be run from Windows PE (Preinstallation Environment)
Examples
Initialize the system partition using files from the operating system image installed on the C: volume:
C:\> bcdboot C:\Windows
Set the default BCD locale to Japanese, and copy BCD (Boot Configuration Data) files to drive S:
C:\> bcdboot C:\Windows /l ja-jp /s S:
Merge the OS loader in the current BCD store identified with the given GUID in the new BCD store:
C:\> bcdboot c:\windows /m {d58d10c6-df53-11dc-878f-00064f4f4e08}

Display or change file attributes. Find Filenames.
Syntax ATTRIB [ + attribute | - attribute ] [pathname] [/S [/D]]
Key + : Turn an attribute ON - : Clear an attribute OFF
pathname : Drive and/or filename e.g. C:\*.txt /S : Search the pathname including all subfolders. /D : Process folders as well
attributes:
R Read-only (1) H Hidden (2) A Archive (32) S System (4)
extended attributes: E Encrypted C Compressed (128:read-only) I Not content-indexed L Symbolic link/Junction (64:read-only) N Normal (0: cannot be used for file selection) O Offline P Sparse file T Temporary
The numeric values may be used when changing attributes with VBS/WSHIf no attribute is specified attrib will return the current attribute settings. Used with just the /S option ATTRIB will quickly search for a particular filename.
Hidden and System attributes take priority.
If a file has both the Hidden and System attributes set, you can clear both attributes only with a single ATTRIB command.
For example, to clear the Hidden and System attributes for the RECORD.TXT file, you would type: ATTRIB -S -H RECORD.TXT
File Attributes
You can use wildcards (? and *) with the filename parameter to display or change the attributes for a group of files.
Remember that, if a file has the System or Hidden attribute set, you must clear that attribute before you can change any other attributes.
Directory Attributes
You can display or change the attributes for a directory/folder. To use ATTRIB with a directory, you must explicitly specify the directory name; you cannot use wildcards to work with directories.
For example, to hide the directory C:\SECRET, you would type the following:
ATTRIB +H C:\SECRET
The following command would affect only files, not directories: ATTRIB +H C:*.*
The Read-only attribute for a folder is generally ignored by applications, however the Read-only and System attributes are used by Windows Explorer to determine whether the folder is a special folder, such as My Documents, Favorites, Fonts, etc. Setting the Read-Only attribute on a folder can affect performance, particularly on shared drives because Windows Explorer will be forced to request the Desktop.ini of every sub-folder to see if any special folder settings need to be set.
Viewing archive attributes
The Archive attribute (A) is used to mark files that have changed since they were previously backed up. The (A) flag is automatically updated by Windows as the file is saved.
If the (A) flag is present - the file is new or has been changed since the last backup.
The MSBACKUP, RESTORE, and XCOPY commands use these Archive attributes, as do many (but not all) 3rd party backup solutions.
Extended Attributes
File attributes can be read with fsutil usn readdata filename.ext
Constants - the following attribute values are returned by the GetFileAttributes function:
FILE_ATTRIBUTE_READONLY = 1 (0x1)FILE_ATTRIBUTE_HIDDEN = 2 (0x2)FILE_ATTRIBUTE_SYSTEM = 4 (0x4)FILE_ATTRIBUTE_DIRECTORY = 16 (0x10)FILE_ATTRIBUTE_ARCHIVE = 32 (0x20)FILE_ATTRIBUTE_NORMAL = 128 (0x80)FILE_ATTRIBUTE_TEMPORARY = 256 (0x100)FILE_ATTRIBUTE_SPARSE_FILE = 512 (0x200)FILE_ATTRIBUTE_REPARSE_POINT = 1024 (0x400)FILE_ATTRIBUTE_COMPRESSED = 2048 (0x800)FILE_ATTRIBUTE_OFFLINE = 4096 (0x1000)FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 8192 (0x2000)FILE_ATTRIBUTE_ENCRYPTED = 16384 (0x4000)
For example, a file attribute of 0x120 indicates the Temporary + Archive attributes are set (0x100 + 0x20 = 0x120.)
DFSR will not replicate files if they have the temporary attribute set.The temporary attribute can be removed by using PowerShell to subtract 0x100:
PS C:\> Get-childitem D:\Data -recurse | ForEach-Object -process {if (($_.attributes -band 0x100) -eq 0x100) {$_.attributes = ($_.attributes -band 0xFEFF)}}

One step file association.
This utility does the job of both ASSOC and FTYPE, in one step. ASSOCIATE assigns an extension directly with an executable application. This is done by automatically adding a new FileType to the system registry.
Syntax ASSOCIATE .ext filename [/q /d /f]
Key .ext : Extension to be associated.
filename : Executable program to associate .ext with.
/q : Quiet - Suppress interactive prompts.
/f : Force - Force overwrite or delete without questions.
/d : Delete - Delete the association.
A file extension is the last few characters in a FileName after the period.
So a file called JANUARY.HTML has the file extension .HTML
The File extension is used by Windows NT to determine the type of information stored in the file and therefore which application(s) will be able to display the information in the file. File extensions are not case sensitive and are not limited to 3 characters.
Example: adding a File Association
To add the File Type "SQLfile"=Notepad.exe and also set the File Association of .SQL="SQLfile" run this command:
ASSOCIATE .SQL Notepad.exe
Example: Removing a File Association
ASSOCIATE .SQL /d
Note that /d will delete the File Association but will NOT delete the File Type.
File types created by Associate.exe are always given a name in the form xxxfile, where xxx is the file extension.