Showing posts with label CMD. Show all posts

ParseDateTime.cmd  

Posted by ReelTym

::::::::::::::::::::::::::::::::
:: Parse Date/Time
::
:: Test/Example:
::
::     ParseDateTime.cmd WITHECHO
::     echo date=[%date%] time=[%time%] year=[%year%] month=[%month%] day=[%day%] hour=[%hour%] minute=[%minute%] second=[%second%] hundredth=[%hundredth%]
::
::::::::::::::::::::::::::::::::
@echo off&setlocal
for /f "tokens=1-4 delims=/-. " %%G in ('date /t') do (call :s_fixdate %%G %%H %%I %%J)
goto :s_print_the_date
  
:s_fixdate
if "%1:~0,1%" gtr "9" shift
for /f "skip=1 tokens=2-4 delims=(-)" %%G in ('echo.^|date') do (set %%G=%1&set %%H=%2&set %%I=%3)
goto :eof

:s_print_the_date
endlocal&(
    echo.|date|find "JJ">nul
    if errorlevel 1 (
        :: English locale
        REM echo  year:[%yy%]  month:[%mm%]  day:[%dd%]
        set year=%yy%
        set month=%mm%
        set day=%dd%
    ) else (
        :: German locale
        REM echo  jahr:[%JJ%]  monat:[%MM%]  tag:[%TT%]
        set year=%JJ%
        set month=%MM%
        set day=%TT%
    )
)

for /f "tokens=1-4 delims=.:, " %%i in ("%time%") do (
    set hour=%%i
    set minute=%%j
    set second=%%k
    set hundredth=%%l
)
if %hour% lss 10 set hour=0%hour%

if "%1"=="WITHECHO" echo %year%-%month%-%day% %hour%:%minute%:%second%.%hundredth%

Useful MS DOS Commands  

Posted by ReelTym


Create a 15 second delay (Win98, WinNT, WinXP):
ping -n 15 localhost > NUL
the "localhost" could also be 127.0.0.1, and change the "15" to the number of seconds delay required.

Get the time down to a 100th of a second (WinNT, WinXP):
for /F "tokens=5 delims= " %i in ('echo ^| time ^| find "current" ') do echo %i
if used in a batch file, change the %i to %%i and "echo %i" to something like "set ttn=%%i
or, but only in WinXP:
for /F "tokens=1 delims= " %i in ('echo.%TIME%') do echo %i
or, if you only want to print it directly to the screen and don't need to save it to a variable, use:
echo %TIME%
Could also use:
for /F "tokens=1-3 delims=: " %i in ('time /t') do echo %i%j%k
But have found this last method to be very dependant on the Regional settings of Windows, of which you may or may not have control over and does not have the 100th's.
Got sent the following one from Christoph Sternberg, which works a treat with WinXP, and is a lot easier that the 'for' method:
echo %time:~0,2%%time:~3,2%%time:~6,2%%time:~9,2%
which can also be used in a 'set' command, just as well
set ttrn=%time:~0,2%%time:~3,2%%time:~6,2%%time:~9,2%

Get the date in "yyyymmdd" format (WinNT, WinXP):
for /F "tokens=2-4 delims=/ " %i in ('date /t') do echo %k%i%j
This one does assume the date is displayed as mm/dd/yyyy, with separators of "/" when "date /t" is excuted.
A little playing after checking the output of "date /t" can soon correct any change.
Have found it to be useful when wanting to produce unique daily filenames for log files.
Got sent the following one from Christoph Sternberg, which works a treat with WinXP, and is a lot easier that the 'for' method:
echo %date:~6,4%%date:~3,2%%date:~0,2%
which can also be used in a 'set' command, just as well
set tddt=%date:~6,4%%date:~3,2%%date:~0,2%


Create a new file, or completely blank an existing (Win98, WinNT, WinXP):
type NUL>newfile.txt
This will create a new file named "newfile.txt" with a 0 byte count, it is completely empty.

Change a File's Date and Time Stamp to current (Win98):
copy thefilename.txt /B+ ,,/Y
and if you need to do a bulk change to a whole directory of gif files:
for %i in ('dir *.gif') do copy %i /B+ ,,/Y
which all change the Date/Time stamp of all the files with the extension GIF in the current directory.
Have not tested in WinNT or WinXP yet.

Create a unique filename use date and time (WinNT, WinXP):
The following is a short batch file that uses date and time to create a unique filename.
@echo off
:: file = makenew.bat
::
:: description = this batch file uses current date and time to create a file with a unique filename

::
:: Date         Author    Change/Update
:: 04-Jun-2005  AGButler  Original
::
 
:: set variables
set tdtd=none
set ttrn=none

 
:: get the date and time and then into single variable
for /F "tokens=2-4 delims=/ " %%i in ('date /t') do set tdtd=%%i%%j%%k
for /F "tokens=5-8 delims=:. " %%i in ('echo.^| time ^| find "current" ') do set ttrn=%%i%%j%%k%%l
set tufn=%tdtd%%ttrn%.txt
 
:: now create the file
type NUL>%tufn%
 
:EOF

Will have to play a little with "date" line to get the delims and order of the %%i %%j %%k correct. To check just type date on the command line and use ouput to change. Have not tested in Win98.

Remove or Substitue characters with a variable(winXP):
It is possible to do some neat functions with DOS scripts. One that is often very useful is Removing or Substituting characters with a variable.
So you have a variable that may have some thing like the time, that contain ":" collin characters "20:12:34.54", but you want to remove the collins. This can be done relitively easily with the SET command. The following script will load the time into a variable "ttrn", then remove the collins and then remove the period.
for /F "tokens=5 delims= " %%i in ('echo.^|time^|find "current" ') do set ttrn=%%i 

echo %ttrn%

set ttrn=%ttrn::=%

echo %ttrn%

set ttrn=%ttrn:.=%

echo %ttrn%
You basically have the variable the a : then the character to search for the = then the character to subsitute, if none the a deletion occurs.
variable=%variable:search=replace%
It is also useful, if loading data from a file that may enclosed in quotes, and then just use SET to remove the quotes.

Dealing with large numbers like disk free bytes for Gigabyte capacity drives, 10,000,000,000(winXP):
My problem was that when using the "fsutil" command in WinXP, Win2K and Win2K3 to retrieve the capacity and free bytes of disk drives, that were to large to be able to be used in arithmetic commands. The task was to read the capacity and compare to the free remaining and make a call if the free remaining had dropped below a set level.
The solution was to use a series of SET commands, that could simulate the conversion of Bytes into Gigabytes. OK it is not highly accurate, but it is enough to be able to assess if a drive is 90% free remaining or 2% free remaining or anywhere in between.
What the follow will do is: - put the capacity and free bytes of my C: drive into variables.  - cut off the last 6 digits, simulating conversion from Bytes to Megabytes. - Check to make sure the result has not gone below 1MB, if it has then make it 1MB. - Calculate the capacity used. This will be a number between 1 and the Total Capacity. The smaller the number the more used, or less free. - Then make an action based on the limit set.
:: put the capacity and free bytes of my C: drive into variables from the fsutil command
for /F "tokens=7 delims= " %%i in ('fsutil volume diskfree c:^|find "Total # of free bytes" ') do set ctmp1=%%i
for /F "tokens=6 delims= " %%i in ('fsutil volume diskfree c:^|find "Totel # of bytes" ') do set ctmp2=%%i


:: shorten the strings removing last 6 characters simulating conversion from Bytes to MegaBytes
set ctmp1=%ctmp1:~0,-6%
set ctmp2=%ctmp2:~0,-6%


:: check to ensure that "free bytes" now contains something, if not then make equal to 1
:: the variable will be left as is if it contains anything initially, only changes when nul
if .%ctmp1%==. set ctmp1=1


:: now evaluate using the two variables
:: this will produce a RESULT between 1(plenty of free disk) and the capacity of the drive in MegaBytes(near full)
set /A ctmp3=%ctmp2%/%ctmp1%


:: the following assumes for example a 1GB(1000MB) drive has only 100MB free remaining then = LOW
:: set a dummy result, then make a check
set ctmp4=OK
if %ctmp3% GTR 10 set ctmp4=LOW


:: output the result
echo Your C: Drive remaining capacity = %ctmp4%

It does only produce a simple rough guide, but is effective enough to judge whole percentage changes, which should be able to catch a drive at 10% remaining before it gets to 0%, leaving enough time for some action.
You can also change the 'set dummy and make a check' lines to be a bit more fail safe by:
set ctmp4=LOW
if %ctmp3% LSS 10 set ctmp4=OK
It can take a little bit of playing with, but is an excellent method of keeping an eye on your drive capacities without the need for any fancy software. It is also highly scalable for what ever drive capacity and limits that need to be set or monitored.

Creating and using a variable array in DOS(winXP):
I searched everywhere without success for a method to produce an array in DOS.
This solution has proven to be very successful.
The basics is to use a variable name that has some type of separator, like a period ".", the second half of the variable name can then be substituted with the contents of another variable, following is very a simple example.
:: set the segment variables 
set agbtp.1=A 
set agbtp.2=B 
Notice the period between the 'agbtp' and '1' ?
Next setup or supply a third variable that will be substituted into the array.
:: set the segid
set segid=1
Now put the whole lot in to a FOR-DO to obtain the new variable from the array based on the supplied segid. Note the '^=' in the delims, this allows the search to use the '=' as a separator. The 'find' with the ".variable=" is also necessary to do the correct filtering.
 :: calculate the Segment printed variable
for /F "tokens=2 delims=^=" %%i in ('set agbtp.%segid% ^| find ".%segid%=" ') do set psegid=%%i
This resulted in the variable 'psegid' now containing 'A'.
If the variable 'segid' had been loaded with the value '2', then the 'psegid' would then contain 'B'.
This may all appear very simplistic, but if there was a problem where you wanted to count from 0 to 255, and on each count, produce the output in HEX (00-FF). Setup an array of:
set myhex.0=00
set myhex.1=01
set myhex.2=02
 "    "      " - (repeat from 3 to 252 / 03 to FC)
set myhex.253=FD
set myhex.254=FE
set myhex.255=FF
Set up a counting loop.
set /A cntr=0
set /A scntr=256
:loop
Then substitute in the variable and output the results.
for /F "tokens=2 delims=^=" %%i in ('set myhex.%cntr% ^| find ".%cntr%=" ') do echo %%i
Which can be simplified by removal of the 'find' command to be.
for /F "tokens=2 delims=^=" %%i in ('set myhex.%cntr%') do echo %%i
And loop until finished.
set /A cntr=%cntr%+1
if NOT [%scntr%]==[%cntr%] goto loop
This technique can be used to read data or configuration from a text file, into an array.

ON THE FLY COMPRESSION/UNCOMPRESSION IS EASY ON UNIX, BUT ALSO ON WINDOWS  

Posted by ReelTym

Link to full article

ON THE FLY COMPRESSION IS EASY ON UNIX, BUT IT IS ALSO EASY ON WINDOWS

There are a number of situations where the output results of a program become the input data for other program (for example you may want to compress your backup file with gzip tool and the compressed file be encrypted with Rijndael algorithm using GNU aes tool)

When both programs support stdin and stdout as a mechanism for input output, you can easily pipe the output of the first program to the input of the second program at the command line. For example

gzip –c mybackupfile.bkp | aes –e -p mypass -o mybackupfile.bkp.gz.enc

Unfortunately, this is not always the case and some programs don’t accept stdin and stdout for data input output (this is the case of Oracle import/export tools or Microsoft bcp tool).

On Unix environments these cases have been typically solved using mknod tool to create an OS file pipe. Once the pipe is created, the first program is able to write its output results to the pipe as if it was a normal file and the second program is able to read data from that pipe as if it was a normal file.

As an example, here you can find a largely used script by Oracle DBA to perform on the fly compression of an export operation

# Make a pipe
mknod expdat.dmp p
# Start compress the pipe in background
gzip -c < expdat.dmp > expdat.dmp.gz &
# Wait start the export
sleep 5
# Start the export
exp scott/tiger file=expdat.dmp

As far as I know, there is no similar native way to perform this operation on Microsoft Windows operating system.

I started thinking on it and finally I got a simple solution using Microsoft Windows pipes, zlib library (http://www.zlib.net/zlib123-dll.zip ) and a couple of small tools (less than 100 lines of code each of them)  I wrote: ZipPipe.exe and UnZipPipe.exe.

In point 1, I will show several uses of these tools, basically how to perform on the fly compression using Oracle imp and exp tools.
To get the necessary bin files (ZipPipe.exe, UnZipPipe.exe and zlib1.dll I would suggest to read point 2 and 3 of this document, but if you have any problem to obtain these files, just drop me an e-mail at jcarlossaez1@hotmail.com
Note: You can obtain a compiled version of these tools from http://cid-b3378f057444b65c.skydrive.live.com/self.aspx/P%c3%bablico/ZipPipe/zippipe.zip You don´t need anything more than these to run the tools.

1 HOW TO USE ZipPipe AND UnZipPipe TOOLS


1.1 On the Fly compression with Oracle Exp and Imp tools


On Unix environments, it has been largely used scripts allowing on the fly compression of the dump file generated by exp utility.
In the same way, on the fly decompression can be achieved to perform import operations reading directly from a compressed file.

A typical script to perform on the fly compression for the data generated by exp utility is

# Make a pipe
mknod expdat.dmp p
# Start compress the pipe in background
gzip -c < expdat.dmp > expdat.dmp.gz &
# Wait start the export
sleep 5
# Start the export
exp scott/tiger file=expdat.dmp

A typical script to execute an import operation reading directly from a compressed file is 

# Make a pipe
mknod expdat.dmp p
# Start decompress to the pipe in background
gzip -c < expdat.dmp.gz > expdat.dmp > &
# Wait start the import
sleep 5
# Start the import
imp scott/tiger file=expdat.dmp

There is no way to accomplish this work in the same way on Windows platforms. When exporting you first export to a normal file and then, you can compress it (except using NTFS built-in compression capabilities, but this is not what we are looking for)
When importing, you need first decompress the file and then you can import the file.

However, whit the ZipPipe and UnZipPipe tools, you can achieve the same behaviour as you have on Unix.

How to perform on the fly compression while exporting on Windows platforms?

Until now, your bat scripts looks something similar to this

exp scott/tiger file=expdat.dmp
gzip  expdat.dmp expdat.dmp.gz

Only when exp tool finishes its job, you can start compressing the file. This way needs more disk space and in most of the cases more time.

Look how you can export and compress without any intermediate file

start /MIN ZipPipe EXPPIPE expdat.dmp.gz 9
exp scott/tiger file= \\.\pipe\EXPPIPE

The first line starts our “compressor engine” that listens on named pipe \\.\pipe\EXPPIPE and writes the compressed information to the file expdat.dmp.gz  with a compression level of 9 (compression level can be in the range 1 to 9)
When export tool completes the export operation, ZipPipe process detects it and ends

How to perform on the fly decompression while importing on Windows platforms?

Until now, your bat scripts looks something similar to this

gzip –d expdat.dmp.gz expdat.dmp
imp scott/tiger file=expdat.dmp

Only when decompressor tool finishes its job, you can start importing the file. This way needs more disk space and in most of the cases more time.

Look how you can import and decompress without any intermediate file

start /MIN UnZipPipe IMPPIPE expdat.dmp.gz
imp scott/tiger file= \\.\pipe\IMPIPE

The first line starts our “decompressor engine” that listens that reads from the compressed file expdat.dmp.gz and writes the decompressed information to named pipe \\.\pipe\IMPPIPE
When import tool completes the import operation, UnZipPipe process detects it and ends.

You can think on ZipPipe and UnZipPipe as the equivalent tool to mknod plus gzip in the Unix environment.
Of course, you can make many remarks to this solution, but it allows you to achieve the same functionality you have on Unix, saving lot of space in Disks and most of the times reducing import/export duration.

One more thing: it is a pity these tools don’t work with new expdp and impdp tools available in Oracle10g. But don’t blame to Microsoft Windows or to these tools themselves. You won’t be able to perform on the fly compression with these new tools on Unix environments too. It is due to a change in the design of these tools. (And don’t get wrong with the COMPRESS parameter of these new tools. This parameter only compresses metadata).

1.2 On the Fly compression with Microsoft bcp tool

What a terrible pity! I have been able to use these tools only to on the fly compress the output of the bcp in native format.
I can not use them for on the fly decompression when using bcp to import or even when downloading data in no native format.
Perhaps someone can make them work.

How do you use bcp to export pubs..authors table to an uncompressed file and then compress?

Typically, at the command prompt in the source SQL Server you only need to type:

            bcp  pubs..authors out  authors.txt -T –n
            gzip authors.txt authors.txt.gz

The first command exports the data and the second one compress the generated file using gzip tool

Note that during the process you need enough space to store authors.txt and authors.txt.gz simultaneously provided that at the end you can delete the uncompressed file.

How can you use bcp and ZipPipe to export pubs..authors table directly to a compressed file?

At the command prompt in the source SQL Server you only need to type:

            start /MIN ZipPipe authors_pipe authors.txt.gz 9
            bcp  pubs..authors out  \\.\pipe\authors_pipe -T -n

The first command starts our compressor tool (you can think this step is similar to create a pipe and start the background compressor in the Unix environment all in one step).
Second, you only need to start bcp tool, but giving the pipe \\.pipe\ authors_pipe  as the file name where bcp has to write.

Another  process is launched. This background process is our compressor tool that creates and listens on named pipe \\.pipe\ authors_pipe and saves the data once compressed in the file authors.txt.gz. This process automatically ends when bcp completes export operation.

And you can see how file authors.txt.gz is the only file generated in one step.

Rest of the article where you can find how to build these tools
 http://spaces.msn.com/members/jcarlossaez/Blog/cns!1phQKLZOcIUsN9Tj5QObzgdw!112.entry

DtDNS IP Updater CMD Script  

Posted by ReelTym

Filename: update.cmd

@echo off
cd /d %~dp0
echo ----------------------------- GETTING IP -----------------------------
wget "http://myip.dtdns.com" -o getip.log
type getip.log
del getip.log
if exist index.html (
  set /p MYIP=<index.html
  echo MYIP=%MYIP%
  del index.html
  echo ----------------------------- SETTING IP -----------------------------
  wget "http://www.dtdns.com/api/autodns.cfm?id={domain}&pw={password}&ip=%MYIP%" -o setip.log
  if exist "autodns.cfm*" del autodns.cfm*
  type setip.log
  del setip.log
)

Querying/Resetting/Opening Remote Desktop Connections  

Posted by ReelTym


Log into a server on the domain and open a windows command prompt

qwinsta = Query WINdows STAtion

To view current connections on a server type:
            qwinsta /server:<server name or ip address>

When the results are displayed pick an ID value that has a state of “Disc” (Disconnected)

rwinsta = Reset WINdows STAtion

To kill a session pick the ID with the state of “Disc” and type the following:
            rwinsta <ID Value> /server:<server name or ip address>

The remote desktop session has been killed and you are now able to Remote Desktop into your original SQL Server.

Starting Remote Desktop from the Command-Line......

If you may wan to run Desktop Console from a batch file, for example RDC over VPN, you can use mstsc /v:servername /console command.

Mstsc

Creates connections to terminal servers or other remote computers, edits an existing Remote Desktop Connection (.rdp) configuration file, and migrates legacy connection files that were created with Client Connection Manager to new .rdp connection files.

Syntax

            mstsc.exe {ConnectionFile | /v:ServerName[:Port]} [/console] [/f] [/w:Width /h:Height]
            mstsc.exe /edit"ConnectionFile"
            mstsc.exe /migrate

Parameters
            ConnectionFile
                        Specifies the name of an .rdp file for the connection.

            /v:ServerName[:Port]
                        Specifies the remote computer and, optionally, the port number to which you want to connect.

            /console
                        Connects to the console session of the specified Windows Server 2003 family operating system.

            /f
                        Starts Remote Desktop connection in full-screen mode.

            /w:Width /h:Height
                        Specifies the dimensions of the Remote Desktop screen.

            /edit"ConnectionFile"
                        Opens the specified .rdp file for editing.

            /migrate
                        Migrates legacy connection files that were created with Client Connection Manager to new .rdp connection files.

Remarks

You must be an administrator on the server to which you are connecting to create a remote console connection.
default.rdp is stored for each user as a hidden file in My Documents. User created .rdp files are stored by default in My Documents but can be moved anywhere.
Examples

To connect to the console session of a server, type:

            mstsc /console

To open a file called filename.rdp for editing, type:

            mstsc /edit filename.rdp

Command line reference: Database and Operating Systems  

Posted by ReelTym

                 
  Oracle   Oracle database
dict.
  CMD Commands   Windows XP
+ Resource Kits, Robocopy
 
  Bash   BASH
GNU Linux
  VBScript   VBScript Commands  
  OS X Commands   OS X commands
Leopard 10.5
  Powershell   Windows PowerShell  
  Forum   Discussion
Forums
  SQL Server   SQL Server database  
                 

CMD: Windows XP Command Line Syntax  

Posted by ReelTym

   Parameters    Command Line Parameters  %1  %~f1 
   Variables     Create/read environment variables
   Redirection   Spooling output to a file, piping input
   AND/OR Logic  Conditional Execution (If-Then-Else)
   Loops         Loops and Subroutines
   functions     How to package blocks of code
Services     List of Windows XP Services

Evaluating expressions
   Using brackets to Group and expand expressions
   Delayed Expansion Manage <xml> and <html> text
   SET /A        Environment variable arithmetic
   VarSubstring  Extract part of a variable (substring)
   VarSearch     Search & replace part of a variable
   Escape chars, delimiters and quotes
   Wildcards     Match multiple files

Batch Files 
   DateMath      Add or subtract days from any date
   GetDate.cmd   Get todays date (any region, any OS)
   GetTime.cmd   Get the time now 
   GetGMT.cmd    Time adjusted to Greenwich Mean Time
   datetime.vbs  Get Date, Time and daylight savings 
   deQuote       Remove quotes from a string
   DelOlder.cmd  Delete files more than n days old
   StampMe.cmd   Rename a file with the date/time
   Which.cmd     Display full path to any command
   DragDrop.cmd  Drag and drop onto a batch script

Reference/How to
   RUN commands   Start-Run Snap-Ins and Control panel applets
   Slow Browsing  Speed up network browsing
   Printing       Printer connections and print drivers
   Qchange        Script to change Printer connections
   Desktop Heap   Memory configuration
   Permissions    Local vs Global workgroups
   Long Filenames NTFS filename issues
   WorkGroups     Built-In Users and Security Groups
   autoexec       Run commands at startup
   Recovery       The Recovery Console
   WinXP Registry User interface settings


Related: Microsoft.com - Command-line Reference 

CMD: An A-Z Index of the Windows XP command line  

Posted by ReelTym

a
   ADDUSERS Add or list users to/from a CSV file
   ARP      Address Resolution Protocol
   ASSOC    Change file extension associations•
   ASSOCIAT One step file association
   ATTRIB   Change file attributes
b
   BOOTCFG  Edit Windows boot settings
   BROWSTAT Get domain, browser and PDC info
c
   CACLS    Change file permissions
   CALL     Call one batch program from another•
   CD       Change Directory - move to a specific Folder•
   CHANGE   Change Terminal Server Session properties
   CHKDSK   Check Disk - check and repair disk problems
   CHKNTFS  Check the NTFS file system
   CHOICE   Accept keyboard input to a batch file
   CIPHER   Encrypt or Decrypt files/folders
   CleanMgr Automated cleanup of Temp files, recycle bin
   CLEARMEM Clear memory leaks
   CLIP     Copy STDIN to the Windows clipboard.
   CLS      Clear the screen•
   CLUSTER  Windows Clustering
   CMD      Start a new CMD shell
   CMDKEY   Manage stored usernames/passwords
   COLOR    Change colors of the CMD window•
   COMP     Compare the contents of two files or sets of files
   COMPACT  Compress files or folders on an NTFS partition
   COMPRESS Compress individual files on an NTFS partition
   CON2PRT  Connect or disconnect a Printer
   CONVERT  Convert a FAT drive to NTFS.
   COPY     Copy one or more files to another location•
   CSCcmd   Client-side caching (Offline Files)
   CSVDE    Import or Export Active Directory data 
d
   DATE     Display or set the date•
   DEFRAG   Defragment hard drive
   DEL      Delete one or more files•
   DELPROF  Delete NT user profiles
   DELTREE  Delete a folder and all subfolders
   DevCon   Device Manager Command Line Utility 
   DIR      Display a list of files and folders•
   DIRUSE   Display disk usage
   DISKCOMP Compare the contents of two floppy disks
   DISKCOPY Copy the contents of one floppy disk to another
   DISKPART Disk Administration
   DNSSTAT  DNS Statistics
   DOSKEY   Edit command line, recall commands, and create macros
   DSACLs   Active Directory ACLs
   DSAdd    Add items to active directory (user group computer) 
   DSGet    View items in active directory (user group computer)
   DSQuery  Search for items in active directory (user group computer)
   DSMod    Modify items in active directory (user group computer)
   DSMove   Move an Active directory Object
   DSRM     Remove items from Active Directory
e
   ECHO     Display message on screen•
   ENDLOCAL End localisation of environment changes in a batch file•
   ERASE    Delete one or more files•
   EVENTCREATE Add a message to the Windows event log
   EXIT     Quit the current script/routine and set an errorlevel•
   EXPAND   Uncompress files
   EXTRACT  Uncompress CAB files
f
   FC       Compare two files
   FIND     Search for a text string in a file
   FINDSTR  Search for strings in files
   FOR /F   Loop command: against a set of files•
   FOR /F   Loop command: against the results of another command•
   FOR      Loop command: all options Files, Directory, List•
   FORFILES Batch process multiple files
   FORMAT   Format a disk
   FREEDISK Check free disk space (in bytes)
   FSUTIL   File and Volume utilities
   FTP      File Transfer Protocol
   FTYPE    Display or modify file types used in file extension associations•
g
   GLOBAL   Display membership of global groups
   GOTO     Direct a batch program to jump to a labelled line•
   GPUPDATE Update Group Policy settings
h
   HELP     Online Help
i
   iCACLS   Change file and folder permissions
   IF       Conditionally perform a command•
   IFMEMBER Is the current user in an NT Workgroup
   IPCONFIG Configure IP
k
   KILL     Remove a program from memory
l
   LABEL    Edit a disk label
   LOCAL    Display membership of local groups
   LOGEVENT Write text to the NT event viewer
   LOGMAN   Manage Performance Monitor
   LOGOFF   Log a user off
   LOGTIME  Log the date and time in a file
m
   MAPISEND Send email from the command line
   MBSAcli  Baseline Security Analyzer. 
   MEM      Display memory usage
   MD       Create new folders•
   MKLINK   Create a symbolic link (linkd)
   MODE     Configure a system device
   MORE     Display output, one screen at a time
   MOUNTVOL Manage a volume mount point
   MOVE     Move files from one folder to another•
   MOVEUSER Move a user from one domain to another
   MSG      Send a message
   MSIEXEC  Microsoft Windows Installer
   MSINFO   Windows NT diagnostics
   MSTSC    Terminal Server Connection (Remote Desktop Protocol)
   MUNGE    Find and Replace text within file(s)
   MV       Copy in-use files
n
   NET      Manage network resources
   NETDOM   Domain Manager
   NETSH    Configure Network Interfaces, Windows Firewall & Remote access
   NETSVC   Command-line Service Controller
   NBTSTAT  Display networking statistics (NetBIOS over TCP/IP)
   NETSTAT  Display networking statistics (TCP/IP)
   NOW      Display the current Date and Time 
   NSLOOKUP Name server lookup
   NTBACKUP Backup folders to tape
   NTRIGHTS Edit user account rights
o
   OPENFILES Query or display open files
p
   PATH     Display or set a search path for executable files•
   PATHPING Trace route plus network latency and packet loss
   PAUSE    Suspend processing of a batch file and display a message•
   PERMS    Show permissions for a user
   PERFMON  Performance Monitor
   PING     Test a network connection
   POPD     Restore the previous value of the current directory saved by PUSHD•
   PORTQRY  Display the status of ports and services
   POWERCFG Configure power settings
   PRINT    Print a text file
   PRINTBRM Print queue Backup/Recovery
   PRNCNFG  Display, configure or rename a printer
   PRNMNGR  Add, delete, list printers set the default printer
   PROMPT   Change the command prompt•
   PsExec     Execute process remotely
   PsFile     Show files opened remotely
   PsGetSid   Display the SID of a computer or a user
   PsInfo     List information about a system
   PsKill     Kill processes by name or process ID
   PsList     List detailed information about processes
   PsLoggedOn Who's logged on (locally or via resource sharing)
   PsLogList  Event log records
   PsPasswd   Change account password
   PsService  View and control services
   PsShutdown Shutdown or reboot a computer
   PsSuspend  Suspend processes
   PUSHD    Save and then change the current directory•
q
   QGREP    Search file(s) for lines that match a given pattern.
r
   RASDIAL  Manage RAS connections
   RASPHONE Manage RAS connections
   RECOVER  Recover a damaged file from a defective disk.
   REG      Registry: Read, Set, Export, Delete keys and values
   REGEDIT  Import or export registry settings
   REGSVR32 Register or unregister a DLL
   REGINI   Change Registry Permissions
   REM      Record comments (remarks) in a batch file•
   REN      Rename a file or files•
   REPLACE  Replace or update one file with another
   RD       Delete folder(s)•
   RMTSHARE Share a folder or a printer
   ROBOCOPY Robust File and Folder Copy
   ROUTE    Manipulate network routing tables
   RUNAS    Execute a program under a different user account
   RUNDLL32 Run a DLL command (add/remove print connections)
s
   SC       Service Control
   SCHTASKS Schedule a command to run at a specific time
   SCLIST   Display NT Services
   SET      Display, set, or remove environment variables•
   SETLOCAL Control the visibility of environment variables•
   SETX     Set environment variables permanently
   SFC      System File Checker 
   SHARE    List or edit a file share or print share
   SHIFT    Shift the position of replaceable parameters in a batch file•
   SHORTCUT Create a windows shortcut (.LNK file)
   SHOWGRPS List the NT Workgroups a user has joined
   SHOWMBRS List the Users who are members of a Workgroup
   SHUTDOWN Shutdown the computer
   SLEEP    Wait for x seconds
   SLMGR    Software Licensing Management (Vista/2008)
   SOON     Schedule a command to run in the near future
   SORT     Sort input
   START    Start a program or command in a separate window•
   SU       Switch User
   SUBINACL Edit file and folder Permissions, Ownership and Domain
   SUBST    Associate a path with a drive letter
   SYSTEMINFO List system configuration
t
   TASKLIST List running applications and services
   TASKKILL Remove a running process from memory
   TIME     Display or set the system time•
   TIMEOUT  Delay processing of a batch file
   TITLE    Set the window title for a CMD.EXE session•
   TLIST    Task list with full path
   TOUCH    Change file timestamps    
   TRACERT  Trace route to a remote host
   TREE     Graphical display of folder structure
   TYPE     Display the contents of a text file•
   TypePerf Write performance data to a log file
u
   USRSTAT  List domain usernames and last login
v
   VER      Display version information•
   VERIFY   Verify that files have been saved•
   VOL      Display a disk label•
w
   WHERE    Locate and display files in a directory tree
   WHOAMI   Output the current UserName and domain
   WINDIFF  Compare the contents of two files or sets of files
   WINMSD   Windows system diagnostics
   WINMSDP  Windows system diagnostics II
   WINRM    Windows Remote Management
   WINRS    Windows Remote Shell
   WMIC     WMI Commands
x
   XCACLS   Change file and folder permissions
   XCOPY    Copy files and folders
   ::       Comment / Remark• 
y
z
Commands marked • are Internal commands only available within the CMD shell.
All other commands (not marked with •) are external commands which may be used under the CMD shell, PowerShell, or directly from START-RUN.