Programming Languages / Windows Batch Instructions or commands


ASSOC
Definition Displays / modify the file extension associations.
Syntax
assoc [<.[ext]>[=[]]]
Example
assoc | more  -----------------------------Display all file extensions
assoc .txt -----------------------------remove the file type association
assoc .bak= -----------------------------remove the file type association


ATTRIB
Definition Display file name / changes file attributes
Syntax
ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] [+O | -O] [+I | -I] [+X | -X] [+P | -P] [+U | -U] 
[drive:][path][filename] [/S [/D]] [/L]

  +   Sets an attribute.
  -   Clears an attribute.

  R   Read-only file attribute.
  A   Archive file attribute.
  S   System file attribute.
  H   Hidden file attribute.
  O   Offline attribute.
  I   Not content indexed file attribute.
  X   No scrub file attribute.
  V   Integrity attribute.
  P   Pinned attribute.
  U   Unpinned attribute.
  B   SMR Blob attribute.
  [drive:][path][filename]
      Specifies a file or files for attrib to process.
  /S  Processes matching files in the current folder
      and all subfolders.
  /D  Processes folders as well.
  /L  Work on the attributes of the Symbolic Link versus
      the target of the Symbolic Link

Example
attrib +h bb.txt-----------------------------hides bb.txt


BREAK
Definition Sets or clears extended CTRL+C checking.
Syntax
break 
Example
break -----------------------------Exits from the loop / conditional statement


BCDEDIT
Definition Sets properties in boot database to control boot loading.
Syntax
BCDEdit /Command[Argument1] [Argument2] ...
Example
Bcdedit /set {bootmgr} flightsigning off
Bcdedit /set flightsigning off


CACLS
Definition Displays or modifies access control lists (ACLs) of files.
Syntax
CACLS filename [/T] [/M] [/L] [/S[:SDDL]] [/E] [/C] [/G user:perm]
        [/R user [...]] [/P user:perm [...]] [/D user [...]]
    filename      

Displays ACLs.
    /T            Changes ACLs of specified files in
                  the current directory and all subdirectories.
    /L            Work on the Symbolic Link itself versus the target
    /M            Changes ACLs of volumes mounted to a directory
    /S            Displays the SDDL string for the DACL.
    /S:SDDL       Replaces the ACLs with those specified in the SDDL string
                  (not valid with /E, /G, /R, /P, or /D).
    /E            Edit ACL instead of replacing it.
    /C            Continue on access denied errors.
    /G user:perm  Grant specified user access rights.
                  Perm can be: R  Read
             W  Write
             C  Change (write)
             F  Full control
    /R user       Revoke specified user's access rights (only valid with /E).
    /P user:perm  Replace specified user's access rights.
                  Perm can be: N  None
             R  Read
             W  Write
             C  Change (write)
             F  Full control
    /D user       Deny specified user access.
 Wildcards can be used to specify more than one file in a command.
 You can specify more than one user in a command.
 Abbreviations:
    CI - Container Inherit.
         The ACE will be inherited by directories.
    OI - Object Inherit.
         The ACE will be inherited by files.
    IO - Inherit Only.
         The ACE does not apply to the current file/directory.
    ID - Inherited.
         The ACE was inherited from the parent directory's ACL.

Example
For single file Display permissions: CACLS bb.txt
For multiple file Display permissions : CACLS *.txt
For single file Add Read-Only permission: CACLS bb.txt /E /G "Power Users":R
Add Full Control permission to a second group of users: 
CACLS bb.txt /E /G "FinanceUsers":F


CALL
Definition Calls a batch program from another.
Syntax
call [drive:][path] []] 
call [:
Example
CALL bb.bat


CD
Definition Displays the name of or changes the current directory.
Syntax
CD [/D] [drive:][path]
CD [..]
Example
Move to the parent directory: CD ..
move to the ROOT directory: CD \
current working directory: C:\Work> CD
Move to  java directory: CD  C:\java


CHCP
Definition Displays / sets active code page number.
Syntax
CHCP [nnn]
nnn = code page number.
Example
C:\aa>chcp
Active code page: 437


CHDIR
Definition Displays the name of or changes the current directory.
Syntax
CHDIR [/D] [drive:][path]
CHDIR [..]
Example
CHDIR C:\aa


CHKDSK
Definition Checks a disk and displays a status report.
Syntax
CHKDSK [volume[[path]filename]]] [/F] [/V] [/R] [/X] [/I] [/C] [/L[:size]] [/B] [/scan] [/spotfix]

  /F                  Fixes errors on the disk.
  /V                  On FAT/FAT32: Displays the full path and name of every
                      file on the disk.
                      On NTFS: Displays cleanup messages if any.
  /R                  Locates bad sectors and recovers readable information
                      (implies /F, when /scan not specified).
  /L:size             NTFS only:  Changes the log file size to the specified
                      number of kilobytes.  If size is not specified, displays
                      current size.
  /X                  Forces the volume to dismount first if necessary.
                      All opened handles to the volume would then be invalid
                      (implies /F).
  /I                  NTFS only: Performs a less vigorous check of index
                      entries.
  /C                  NTFS only: Skips checking of cycles within the folder
                      structure.
  /B                  NTFS only: Re-evaluates bad clusters on the volume
                      (implies /R)
  /scan               NTFS only: Runs an online scan on the volume
  /forceofflinefix    NTFS only: (Must be used with "/scan")
                      Bypass all online repair; all defects found
                      are queued for offline repair (i.e. "chkdsk /spotfix").
  /perf               NTFS only: (Must be used with "/scan")
                      Uses more system resources to complete a scan as fast as
                      possible. This may have a negative performance impact on
                      other tasks running on the system.
  /spotfix            NTFS only: Runs spot fixing on the volume
  /sdcleanup          NTFS only: Garbage collect unneeded security descriptor
                      data (implies /F).
  /offlinescanandfix  Runs an offline scan and fix on the volume.
  /freeorphanedchains FAT/FAT32/exFAT only: Frees any orphaned cluster chains
                      instead of recovering their contents.
  /markclean          FAT/FAT32/exFAT only: Marks the volume clean if no
                      corruption was detected, even if /F was not specified.
Example
CHKDSK   


CHKNTFS
Definition Displays or modifies the checking of disk at boot time.
Syntax
CHKNTFS volume [...]
CHKNTFS /D
CHKNTFS /T[:time]
CHKNTFS /X volume [...]
CHKNTFS /C volume [...]

  volume         Specifies the drive letter (followed by a colon),
                 mount point, or volume name.
/D             Restores the machine to the default behavior; all drives are
                 checked at boot time and chkdsk is run on those that are
                 dirty.
/T:time        Changes the AUTOCHK initiation countdown time to the
                 specified amount of time in seconds.  If time is not
                 specified, displays the current setting.
/X             Excludes a drive from the default boot-time check.  Excluded
                 drives are not accumulated between command invocations.
/C             Schedules a drive to be checked at boot time; chkdsk will run
                 if the drive is dirty.

Example
chkntfs  [...] 
chkntfs [/d] 
chkntfs [/t[:



Definition Clears the screen.
Syntax
CLS 
Example
CLS 


CMD
Definition Opens a new command prompt from parent command prompt
Syntax
CMD    
Example
CMD    


COLOR
Definition Sets the default console foreground and background colors.
Syntax
COLOR [TWO hex digits]
0 = Black       8 = Gray
1 = Blue        9 = Light Blue
2 = Green       A = Light Green
3 = Aqua        B = Light Aqua
4 = Red         C = Light Red
5 = Purple      D = Light Purple
6 = Yellow      E = Light Yellow
7 = White       F = Bright White
First digit=background
Second digit= foreground

Example
color 07


COMP
Definition Compares contents of 2 files / more files.
Syntax
COMP file1 file2
Example
COMP C:\abcd\alphabets.txt C:\ abcd \numbers.txt


COMPACT
Definition Displays / alters the compression of files on NTFS partitions.
Syntax
compact filename
Example
compact file1.txt


CONVERT
Definition Converts FAT volumes to NTFS. You cannot convert the os Installed Drive.
Syntax
convert Drive-Letter: /fs:ntfs
Example
convert D: /fs:ntfs


COPY
Definition Copies 1 / more files to another location.
Syntax
Copy source destination
Example
copy C:\a.txt c:\abcd


DATE
Definition Displays / sets the date.
Syntax
DATE [/T | date]   
Example
DATE   


DEL
Definition Deletes 1 / more files.
Syntax
del source-file / source-files
Example
del C:\a.txt ----------- Deletes a.txt
del /s *.txt ------------ Deletes all files



Definition list files and folders of current directory.
Syntax
Dir /s (s= subdirectories)
Example
Dir


DISKPART
Definition Displays / configures Disk Partition properties.
Syntax

Example



DOSKEY
Definition Edits command lines, recalls Windows commands and creates macros.
Syntax
doskey /macros 
Example
doskey /macros 


DRIVERQUERY
Definition Displays current device driver status and properties.
Syntax
driverquery
Example
driverquery


ECHO
Definition Displays messages / turns command echoing on / off.
Syntax
ECHO [ON | OFF]
ECHO [message]
Example
hello world


ENDLOCAL
Definition Ends localization of environment changes in a batch file.
Syntax
endlocal
Example
:myfunction
    setlocal
echo hello world
    endlocal
    exit 


ERASE
Definition Deletes 1/ more files.
Syntax
ERASE [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
/P            Prompts for confirmation before deleting each file.
/F            Force deleting of read-only files.
/S            Delete specified files from all subdirectories.
/Q            Quiet mode, do not ask if ok to delete on global wildcard
/A            Selects files to delete based on attributes
Example
ERASE a.bat
ERASE c:\a.bat
ERASE c:\*.bat


EXIT
Definition Quits the CMD.EXE program (command interpreter).
Syntax
EXIT [/B] [exitCode]

/B          specifies to exit the current batch script instead of
              CMD.EXE.  If executed from outside a batch script, it
              will quit CMD.EXE
Example
Exit 1


FC
Definition Compares two files / more sets of files for displaying the differences between them.
Syntax
FC [/A] [/C] [/L] [/LBn] [/N] [/OFF[LINE]] [/T] [/U] [/W] [/nnnn]
   [drive1:][path1]filename1 [drive2:][path2]filename2]

/A         Displays only first and last lines for each set of differences.
/B         Performs a binary comparison.
/C         Disregards the case of letters.
/L         Compares files as ASCII text.
/LBn       Sets the maximum consecutive mismatches to the specified
             number of lines.
/N         Displays the line numbers on an ASCII comparison.
/OFF[LINE] Do not skip files with offline attribute set.
/T         Does not expand tabs to spaces.
/U         Compare files as UNICODE text files.
/W         Compresses white space (tabs and spaces) for comparison.
/nnnn      Specifies the number of consecutive lines that must match
             after a mismatch.

Example
fc a.txt b.txt


FIND
Definition Searches for a text string in a file or files.
Syntax
FIND [/V] [/C] [/N] [/I] [/OFF[LINE]] "string" [[drive:][path]filename[ ...]]
  /V         Displays all lines NOT containing the specified string.
  /C         Displays only the count of lines containing the string.
  /N         Displays line numbers with the displayed lines.
  /I         Ignores the case of characters when searching for the string.
  /OFF[LINE] Do not skip files with offline attribute set.
  "string"   Specifies the text string to find.
  [drive:][path]filename
             Specifies a file or files to search.
Example
FIND "wisdom" C:\wisdommaterials.txt


FINDSTR
Definition Searches for strings in files.
Syntax
findstr stingtofind file-name
Example
findstr Windows proposal.txt


FOR
Definition Runs a specified command for each file in a set of files.
Syntax
FOR %%Var_Name in list do  iteration_Code
Example
@ECHO OFF 
FOR /L %%X IN (0,1,5) DO ECHO %%X


FORMAT
Definition Formats a disk for use with Windows.
Syntax
format Drive-Letter
Example
Format D:\


FSUTIL
Definition Displays / configures the file system properties.
Syntax
FSUTIL file seteof   / 
Example
fsutil fsinfo -------------get file system info


FTYPE
Definition Displays / modifies file types used in file extension associations.
Syntax
ftype [[=[]]]
Example
FTYPE rtffile="C:\Program Files\Windows NT\Accessories\WORDPAD.EXE" "%1"
ASSOC .rtf=rtffile


GOTO
Definition Directs the Windows command interpreter to a labeled line in a batch program.
Syntax
GOTO label
label   Specifies a text string used in the batch program as a label.
Example
GOTO END
ECHO skipped this line
:END
ECHO hello world


GPRESULT
Definition Displays Group Policy information for machine or user.
Syntax
GPRESULT [/S system [/U username [/P [password]]]] [/SCOPE scope]
           [/USER targetusername] [/R | /V | /Z] [(/X | /H)  [/F]]
Parameter List:
/S        system           Specifies the remote system to connect to.
/U        [domain\]user    Specifies the user context under which the
             command should run. Can not be used with /X, /H.
/P        [password]       Specifies the password for the given user
             context. Prompts for input if omitted.
             Cannot be used with /X, /H.
/SCOPE    scope            Specifies whether the user or the
             computer settings need to be displayed.
             Valid values: "USER", "COMPUTER".
    /USER     [domain\]user    Specifies the user name for which the
             RSoP data is to be displayed.
/X               Saves the report in XML format at the
             location and with the file name specified
             by the  parameter. (valid in Windows
             Vista SP1 and later and Windows Server 2008 and later)
/H               Saves the report in HTML format at the
             location and with the file name specified by
             the  parameter. (valid in Windows
             at least Vista SP1 and at least Windows Server 2008)
/F       Forces Gpresult to overwrite the file name
             specified in the /X or /H command.
/R       Displays RSoP summary data.
/V       Specifies that verbose information should
             be displayed. Verbose information provides
             additional detailed settings that have
             been applied with a precedence of 1.
/Z       Specifies that the super-verbose
             information should be displayed. Super-
             verbose information provides additional
             detailed settings that have been applied
             with a precedence of 1 and higher. This
             allows you to see if a setting was set in
             multiple places. See the Group Policy
             online help topic for more information.
    /?       Displays this help message.
Example
GPRESULT /R
GPRESULT /H GPReport.html
GPRESULT /USER targetusername /V
GPRESULT /S system /USER targetusername /SCOPE COMPUTER /Z
GPRESULT /S system /U username /P password /SCOPE USER /V


HELP
Definition Provides Help information for Windows commands.
Syntax
Help command-name
Example
Help dir


ICACLS
Definition Display, modify, backup, restore ACLs for files and directories.
Syntax
ICACLS name /save aclfile [/T] [/C] [/L] [/Q]
    stores the DACLs for the files and folders that match the name
    into aclfile for later use with /restore. Note that SACLs,
    owner, or integrity labels are not saved.
Example
icacls c:\windows\* /save AclFile /T
icacls c:\windows\ /restore AclFile
icacls file /grant Administrator:(D,WDAC)
icacls file /grant *S-1-1-0:(D,WDAC)


IF
Definition Performs conditional processing in batch programs.
Syntax
IF [NOT] ERRORLEVEL number command
IF [NOT] string1==string2 command
IF [NOT] EXIST filename command
Example
if 9==9 echo "Hello world"


LABEL
Definition Creates, changes, or deletes the volume label of a disk.
Syntax
Label / Goto : label
Example
GOTO abcd
GOTO:1234
:abcd
echo show-abcd
:1234
echo show-1234


MD
Definition Creates a directory.
Syntax
MD [drive:]path
Example
md abcd


MKDIR
Definition Creates a directory.
Syntax
MKDIR [drive:]path
Example
MKDIR abcd


MKLINK
Definition Creates Symbolic Links and Hard Links
Syntax
MKLINK [[/D] | [/H] | [/J]] Link Target

/D      Creates a directory symbolic link.  Default is a file
         symbolic link.
/H      Creates a hard link instead of a symbolic link.
/J      Creates a Directory Junction.
        Link    Specifies the new symbolic link name.
        Target  Specifies the path (relative or absolute) that the new link
                refers to.
Example
mklink /h c:\a.txt c:\abcd\b.file


MODE
Definition Configures a system device.
Syntax
Serial port:       MODE COMm[:] [BAUD=b] [PARITY=p] [DATA=d] [STOP=s]
[to=on|off] [xon=on|off] [odsr=on|off]
 [octs=on|off] [dtr=on|off|hs]
 [rts=on|off|hs|tg] [idsr=on|off]
Example
Device Status:     MODE [device] [/STATUS]
Redirect printing: MODE LPTn[:]=COMm[:]
Select code page:  MODE CON[:] CP SELECT=yyy
Code page status:  MODE CON[:] CP [/STATUS]
Display mode:      MODE CON[:] [COLS=c] [LINES=n]
Typematic rate:    MODE CON[:] [RATE=r DELAY=d]


MORE
Definition Displays output one screen at a time.
Syntax
MORE [/E [/C] [/P] [/S] [/Tn] [+n]] < [drive:][path]filename
    [drive:][path]filename  Specifies a file to display one
          screen at a time.
    command-name            Specifies a command whose output
          will be displayed.

    /E      Enable extended features
    /C      Clear screen before displaying page
    /P      Expand FormFeed characters
    /S      Squeeze multiple blank lines into a single line
    /Tn     Expand tabs to n spaces (default 8)
            Switches can be present in the MORE environment
            variable.
    +n      Start displaying the first file at line n
    files   List of files to be displayed. Files in the list
            are separated by blanks.
    If extended features are enabled, the following commands
    are accepted at the -- More -- prompt:
    P n     Display next n lines
    S n     Skip next n lines
    F       Display next file
    Q       Quit
    =       Show line number
    ?       Show help line
     Display next page
       Display next line
Example
more a.txt


MOVE
Definition Moves 1/ more files from one directory to another directory or to rename a directory.
Syntax
MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2

  [drive:][path]filename1 Specifies the location and name of the file
        or files you want to move.
  destination             Specifies the new location of the file. Destination
        can consist of a drive letter and colon, a
        directory name, or a combination. If you are moving
        only one file, you can also include a filename if
        you want to rename the file when you move it.
  [drive:][path]dirname1  Specifies the directory you want to rename.
  dirname2                Specifies the new name of the directory.

  /Y    Suppresses prompting to confirm you want to
        overwrite an existing destination file.
  /-Y    Causes prompting to confirm you want to overwrite
        an existing destination file.
Example
move c:\abcd\*.* c:\temp


OPENFILES
Definition Displays files opened by remote users for a file share.
Syntax
OPENFILES /parameter [arguments]

/Disconnect      Disconnects one or more open files.
/Query           Displays files opened locally or from shared
                     folders.
/Local           Enables / Disables the display of local open files.
Example
OPENFILES /Disconnect /?
OPENFILES /Query /?
OPENFILES /Local /?


PATH
Definition Displays / sets a search path for executable files.
Syntax
PATH [[drive:]path[;...][;%PATH%]
PATH ;
SET PATH=%PATH%;c:\java\bin
Example
Echo %PATH%


PAUSE
Definition Suspends processing of a batch file and displays a message.
Syntax
PAUSE
Example
PAUSE


POPD
Definition Restores the previous value of the current directory saved by PUSHD.
Syntax
POPD 
Example
POPD 


PRINT
Definition Prints a text file.
Syntax
PRINT [/D: device] [[drive:][path]filename[...]]
Example
print C:\wisdommaterials.txt /c /d:LPT1


PROMPT
Definition Changes the Windows command prompt.
Syntax
PROMPT text
Example
PROMPT hi


PUSHD
Definition Saves the current directory then changes it.
Syntax
pushd path
Example
pushd %1
del *.txt
popd
cls
echo All text files deleted in the %1 directory


RD
Definition Removes a directory.
Syntax
rd Directory-Name
Example
rd C:\abcd


RECOVER
Definition Recovers readable information from a bad / defective disk.
Syntax
RECOVER [drive:][path]filename
Example
RECOVER C:\abcd.txt


REM
Definition Create comments (remarks) in batch files
Syntax
Rem comment   
Example
Rem this is a comment   


REN
Definition Renames a file / files.
Syntax
REN [drive:][path]filename1 filename2.
Example
REN C:\a.txt


RENAME
Definition Renames a file / files.
Syntax
RENAME [drive:][path]filename1 filename2.
Example
RENAME [drive:][path]abcd.txt


REPLACE
Definition Replaces files.
Syntax
REPLACE [drive1:][path1]filename [drive2:][path2] [/A] [/P] [/R] [/W]

/A      Adds new files to destination directory. Cannot
         use with /S or /U switches.
/P       Prompts for confirmation before replacing a file or adding a source file.
/R       Replaces read-only files as well as unprotected         files.
  /S     Replaces files in all subdirectories of the
         destination directory. Cannot use with the /A
         switch.
/W   Waits for you to insert a disk before beginning.
/U     Replaces (updates) only files that are older than
         source files. Cannot use with the /A switch.
Example
REPLACE C:\a.txt C:\b.txt


RMDIR
Definition Removes a directory.
Syntax
RMDIR [/S] [/Q] [drive:]path

/S      Removes all directories and files in the specified directory in addition to   the directory itself.  
        Used to remove a directory tree.
/Q      Quiet mode, do not ask if ok to remove a directory tree with /S
Example
del C:\abcd
del abcd , efgh


ROBOCOPY
Definition Advanced utility to copy files and directory trees
Syntax
robocopy   [[ ...]] []
Example
robocopy c:\abcd\source c:\efgh\destination 


SET
Definition Displays, sets, removes Windows environment variables.
Syntax
SET [variable=[string]]
Example
set path=C:\Program Files\Java\jdk1.6.0_23\bin
set include=c:\directory


SETLOCAL
Definition Begins localization of environment changes in a batch file.
Syntax
SETLOCAL       
Example
SETLOCAL       
Rem Declare variables here
ENDLOCAL


SC
Definition Displays or configures services (background processes).
Syntax
sc  [command] [service name]  ...
  query-----------Queries the status for a service, or
        enumerates the status for types of services.
          queryex---------Queries the extended status for a service, or
        enumerates the status for types of services.
          start-----------Starts a service.
          pause-----------Sends a PAUSE control request to a service.
          interrogate-----Sends an INTERROGATE control request to a service.
          continue--------Sends a CONTINUE control request to a service.
          stop------------Sends a STOP request to a service.
          config----------Changes the configuration of a service (persistent).
          description-----Changes the description of a service.
          failure---------Changes the actions taken by a service upon failure.
          failureflag-----Changes the failure actions flag of a service.
          sidtype---------Changes the service SID type of a service.
          privs-----------Changes the required privileges of a service.
          managedaccount--Changes the service to mark the service account
        password as managed by LSA.
          qc--------------Queries the configuration information for a service.
          qdescription----Queries the description for a service.
          qfailure--------Queries the actions taken by a service upon failure.
          qfailureflag----Queries the failure actions flag of a service.
          qsidtype--------Queries the service SID type of a service.
          qprivs----------Queries the required privileges of a service.
          qtriggerinfo----Queries the trigger parameters of a service.
          qpreferrednode--Queries the preferred NUMA node of a service.
          qmanagedaccount-Queries whether a services uses an account with a
        password managed by LSA.
          qprotection-----Queries the process protection level of a service.
          quserservice----Queries for a local instance of a user service template.
          delete----------Deletes a service (from the registry).
          create----------Creates a service. (adds it to the registry).
          control---------Sends a control to a service.
          sdshow----------Displays a service's security descriptor.
          sdset-----------Sets a service's security descriptor.
          showsid---------Displays the service SID string corresponding to an arbitrary name.
          triggerinfo-----Configures the trigger parameters of a service.
          preferrednode---Sets the preferred NUMA node of a service.
          GetDisplayName--Gets the DisplayName for a service.
          GetKeyName------Gets the ServiceKeyName for a service.
          EnumDepend------Enumerates Service Dependencies.

        The following commands don't require a service name:
        sc   
Example
sc start MyService


SCHTASKS
Definition Schedules commands and programs to run on a computer.
Syntax
CHTASKS /parameter [arguments]
Parameter List:
    /Create         Creates a new scheduled task.
    /Delete         Deletes the scheduled task(s).
    /Query          Displays all scheduled tasks.
    /Change         Changes the properties of scheduled task.
    /Run            Runs the scheduled task on demand.
    /End            Stops the currently running scheduled task.
    /ShowSid        Shows the security identifier corresponding to a scheduled task name.
    /?              Displays this help message.
Example
SCHTASKS
SCHTASKS /?
SCHTASKS /Run /?
SCHTASKS /End /?
SCHTASKS /Create /?
SCHTASKS /Delete /?
SCHTASKS /Query  /?
SCHTASKS /Change /?
SCHTASKS /ShowSid /?


SHIFT
Definition Shifts the position of replaceable parameters in batch files.
Syntax
SHIFT [/n]
Example
SHIFT /2


SHUTDOWN
Definition Allows proper local or remote shutdown of machine.
Syntax
SHUTDOWN [/i | /l | /s | /sg | /r | /g | /a | /p | /h | /e | /o] [/hybrid] [/soft] [/fw] [/f]
    [/m \\computer][/t xxx][/d [p|u:]xx:yy [/c "comment"]]

    No args    Display help. This is the same as typing /?.
    /?         Display help. This is the same as not typing any options.
    /i         Display the graphical user interface (GUI).
               This must be the first option.
    /l         Log off. This cannot be used with /m or /d options.
    /s         Shutdown the computer.
    /sg        Shutdown the computer. On the next boot, if Automatic Restart Sign-On
               is enabled, automatically sign in and lock last interactive user.
               After sign in, restart any registered applications.
    /r         Full shutdown and restart the computer.
    /g         Full shutdown and restart the computer. After the system is rebooted,
               if Automatic Restart Sign-On is enabled, automatically sign in and
               lock last interactive user.
               After sign in, restart any registered applications.
    /a         Abort a system shutdown.
               This can only be used during the time-out period.
               Combine with /fw to clear any pending boots to firmware.
    /p         Turn off the local computer with no time-out or warning.
               Can be used with /d and /f options.
    /h         Hibernate the local computer.
               Can be used with the /f option.
    /hybrid    Performs a shutdown of the computer and prepares it for fast startup.
               Must be used with /s option.
    /fw        Combine with a shutdown option to cause the next boot to go to the
               firmware user interface.
    /e         Document the reason for an unexpected shutdown of a computer.
    /o         Go to the advanced boot options menu and restart the computer.
               Must be used with /r option.
    /m \\computer Specify the target computer.
    /t xxx     Set the time-out period before shutdown to xxx seconds.
               The valid range is 0-315360000 (10 years), with a default of 30.
               If the timeout period is greater than 0, the /f parameter is
               implied.
    /c "comment" Comment on the reason for the restart or shutdown.
               Maximum of 512 characters allowed.
    /f         Force running applications to close without forewarning users.
               The /f parameter is implied when a value greater than 0 is
               specified for the /t parameter.
    /d [p|u:]xx:yy  Provide the reason for the restart or shutdown.
               p indicates that the restart or shutdown is planned.
               u indicates that the reason is user defined.
               If neither p nor u is specified the restart or shutdown is
               unplanned.
               xx is the major reason number (positive integer less than 256).
               yy is the minor reason number (positive integer less than 65536).
Example
shutdown -t 30 –r –f


SORT
Definition Sorts input file / files
Syntax
Sort File-Name
Example
Sort C:\abcd.txt


START
Definition create a new window to run a specified program / command.
Syntax
START
Example
START


SUBST
Definition Associates a path with a drive letter.
Syntax
SUBST [drive1: [drive2:]path]
SUBST drive1: /D

  drive1:        Specifies a virtual drive to which you want to assign a path.
  [drive2:]path  Specifies a physical drive and path you want to assign to
                 a virtual drive.
  /D             Deletes a substituted (virtual) drive.

Type SUBST with no parameters to display a list of current virtual drives.
Example
SUBST d: /D


SYSTEMINFO
Definition Displays machine specific properties and configuration.
Syntax
SYSTEMINFO 
Example
SYSTEMINFO 


TASKLIST
Definition Kill / stop a running process / application.
Syntax
TASKKILL [/S system [/U username [/P [password]]]]
         { [/FI filter] [/PID processid | /IM imagename] } [/T] [/F]

Parameter List:
/S    system           Specifies the remote system to connect to.
/U    [domain\]user    Specifies the user context under which the
         command should execute.
/P    [password]       Specifies the password for the given user
         context. Prompts for input if omitted.
/FI   filter           Applies a filter to select a set of tasks.
         Allows "*" to be used. ex. imagename eq acme*
/PID  processid        Specifies the PID of the process to be terminated.
         Use TaskList to get the PID.
/IM   imagename        Specifies the image name of the process
         to be terminated. Wildcard '*' can be used
         to specify all tasks or image names.
/T                     Terminates the specified process and any
         child processes which were started by it.
/F                     Specifies to forcefully terminate the process(es).
Example
TASKKILL /IM notepad.exe
TASKKILL /F /IM cmd.exe /T


TIME
Definition Displays / sets the system time.
Syntax
TIME [/T | time]
Example
TIME 


TITLE
Definition Sets the window title for a CMD.EXE session.
Syntax
TITLE [text]
Example
TITLE Hi


TREE
Definition Graphically displays the directory structure of a drive or path.
Syntax
TREE [drive:][path] [/F] [/A]

   /F   Display the names of the files in each folder.
   /A   Use ASCII instead of extended characters.
Example
TREE


TYPE
Definition Displays the contents of a text file.
Syntax
TYPE [drive:][path]filename
Example
TYPE C:\a.txt


VER
Definition Displays the Windows version.
Syntax
VER   
Example
VER   


VERIFY
Definition Tells Windows whether to verify that your files are written correctly to a disk.
Syntax
VERIFY [ON | OFF]   
Example
   VERIFY ON


VOL
Definition Displays a disk volume label and serial number.
Syntax
   VOL [drive:]
Example
VOL 
Volume in drive C has no label.
Volume Serial Number is E026-30CA   


XCOPY
Definition Copies files and directory trees.
Syntax
   Xcopy source destination
Example
   xcopy C:\abcd E:\abcd /i


WMIC
Definition Displays WMI information inside interactive command shell.
Syntax
   WMIC BIOS
Example
   WMIC BIOS
WMIC BIOS Get /Format:list
WMIC BIOS Get Manufacturer,Name,Version /Format:htable





Home     Back