Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Contents
SometimesDOSistheBestTool ............................ 1
UsingDOSCommands ........................................... 1
CommandLineStatements ............................... 1
Batch(BAT)Files.............................................. 2
Switches ............................................................ 2
Help................................................................... 2
DOSConsoleWindowOperation.......................... 3
ConsoleSystemMenu....................................... 3
ConsoleWindowKeys....................................... 3
HelpfulDOSCommands........................................ 3
DOSFileCommands ............................................... 3
CHKDSK,toCheckDiskDrive.............................. 4
Syntax ............................................................... 4
Examples ........................................................... 4
CD,toChangeCurrentDirectory.......................... 4
Syntax ............................................................... 4
Examples ........................................................... 5
MD,toCreateaDirectory....................................... 5
Syntax ............................................................... 5
Examples ........................................................... 5
RMorRMDIR,toDeleteDirectories..................... 5
Syntax............................................................... 5
XCOPY,toCopyFilesandDirectories ................. 6
Syntax............................................................... 6
Examples........................................................... 7
DIR,toListFiles ...................................................... 8
Syntax............................................................... 8
Examples........................................................... 9
TREE,toDisplayFolderStructure........................ 9
DEL,toDeleteFile(s) .............................................. 9
REN,toRenameFileorDirectory....................... 10
PING,toVerifyNetworkConnection ................ 10
TRACERT,toTracePacketRouteOver
Network............................................................. 11
MEM,toViewMemoryAmount ........................ 12
FORMAT,toClearHardDriveorData
StorageDevice................................................... 12
NETSTAT,toMonitorUseofPorts .................... 13
Example1 ....................................................... 14
Example2 ....................................................... 15
TASKLIST,toListRunningPrograms................ 16
PortUsageAdvicefromGoogle.......................... 18
DOScommandsarecaseinsensitive.
DOScommandsaredocumentedonvariouswebsitesandintheWindowshelpfile(seeCommand
ReferenceMainPage).
Command Line Statements
TorunDOScommands:
1. OpentheDOScommandconsolewindow(akacommandprompt):
(a) UsemenuStart,Run,entercmd.exeOR
(b) UsemenuStart,Programs,CommandPrompt
2. Typeinthecommand.
3. Press[Enter].
TheconsolewindowiswheretheDOScommandinterpretercanberunondemand.Thecommand
interpreterisCMD.EXE(forWindowsNT,2000,andXP)andCOMMAND.COM(forolderversionsand
backwardscompatibility).CMD.EXEisinc:\windows\system32.
Revision: 6/8/2012 Page 1 of 18
Copyright 20042012 Susan Dorey Designs
DOS Tools
Theconsolewindowopensatthedefaultdirectory.ForWindowsXPthisisc:\Documentsand
Settings\Owner.Thecurrentdirectoryisalwaysdisplayedimmediatelytotheleftofthe>character.You
typecommandstotherightofthe>character.Anewpromptappearswhenthecurrentcommandis
completed.
Batch (BAT) Files
Batchfiles,namedx.BAT,arecollectionsofDOScommandsandspecialbatchfilecommands.Thebatchfile
approachmakesiteasytorerunthecommand(s)andalsodocumentsitforfutureuse.
AbatchfileisrunbyopeningitinWindowsExplorer,i.e.,doubleclickingitsname.Whathappensisthat
whenyouopenaBATfile,theDOScommandconsolewindowopens,theBATfilecommandsarerun,
andthewindowisclosed,allofwhichhappensintheblinkofaneye.
Batchfilesaredescribedindetailat
www.computerhope.com/batch.htm
homepages.cambrianc.on.ca/isp1251/lab/BATCH1.html
IvebeenhavingtroublerunningBATfilesbydoubleclickingtheirnames.IcreatedaFileTypeforthem
witheditandopenactions,theformerusingPFEandthelatterusingCMD.EXE.ThenIwasabletoopen
theCMDwindowbutnothinghappened,soItypedthenameoftheBATfileanditran!Well,apparently,
becauseIcannotfindtheresults.AndtheBATfiledisappeared!Itmaybethatyouhavetocreatethe
directoryintowhichyouplaceyourbackupfiles.
Switches
Mostcommandshaveswitcheswhichactsasargumentsorparameters.
? Displaysacompletelistofavailablecommandlineoptionsforsome
DOScommands.
/? Displaysacompletelistofavailablecommandlineoptionsforsome
DOScommands.
/P Pause
|MORE Displayscommandoutputonescreenatatime.Youwillbepromptedto
typeanykeytodisplaythenextscreenoftext.
>filename Redirectsoutputtonamedfile.
>>filename Appendsoutputtonamedfile
>lpt1 Redirectsoutputtoadevice,LPT1inthiscase.
Help
YoucanseehelpfortheDOScommandsbyaparameterafterDOScommand.
Examples:
dirhelp(doesntworkwithchkdsk)
dir/?
Revision: 6/8/2012 Page 2 of 18
Copyright 20042012 Susan Dorey Designs
DOS Tools
DOS Console Window Operation
Console System Menu
Thesystemmenuisaccessedwiththeiconintheupperleftcorner.Youcanchangethewindowsize,font,
andcolors.Youcanalsouseitforediting(ithasactionsforfind,copy,paste,andselectall).
TheSystemmenucanbeopenedinthreeways:(1)leftclicktheicon,(2)rightclickanywhereinthetitlebar,
or(3)withshortcutkeys[Alt+Spacebar].
Console Window Keys
[] retrievespreviouscommand,whichyoucantheneditbeforeusing
[F7] openspopupwindowwithcommandhistory
Helpful DOS Commands
HELP<command> Displayhelpofnamedcommand.Example:helpdir
TITLE Settitleofcommandconsolewindow.Helpfulwithusingmorethanone
windowatatime.
EXIT EndsCommandPromptsessionandclosestheconsolewindow.
DOS File Commands
ThereisacommandlinereferenceAZintheWindowsHelpfile.
ATTRIB Displayandchangefileattributes
CD,CHDIR Changecurrentdirectory
CHKDSK Checkadiskdriveforerrors
CHKNTFS ChecktheharddiskdriverunningNTFSforerrors
COPY Copyoneormorefilestoasecondlocation
DEL,DELETE,ERASE Deleteoneormorefiles
DELTREE Deleteoneormorefilesand/ordirectories;notforWindowsXP
DIR Listthecontentsofoneormoredirectory
DISKCOPY Copythecontentsofonediskandplacethemonanotherdisk
MD,MKDIR Createanewdirectory
MOVE Moveoneormorefilesfromonedirectorytoanotherdirectory
RD,RMDIR Removeoneormoredirectories
REN,RENAME Renameafileordirectory
TREE Viewavisualtreeoftheharddiskdrive
UNDELETE Undeleteafilethathasbeendeleted
XCOPY Copymultiplefiles,directories,and/ordrivesfromonelocationto
another.Usefulforbackups.
Revision: 6/8/2012 Page 3 of 18
Copyright 20042012 Susan Dorey Designs
DOS Tools
CHKDSK, to Check Disk Drive
Checksthecomputersharddiskdrivesforerrors.
Syntax
CHKDSK [ dr i ve: ]
CHKDSK [ dr i ve: ] [ pat h] speci f i es dr i ve and di r ect or y t o check
CHKDSK [ dr i ve: ] [ pat h] f i l ename] speci f i es f i l e( s) t o check f or f r agment at i on
Switches:
/F Fixerrorsonthedisk.
/R Locatebadsectorsandrecoverreadableinformation(WindowsXP).
/V Displaythefullpathandnameofeveryfileonthedisk.
[none] Omitallswitchestocheckthecurrentdisk.
Examples
chkdsk i :
CheckdriveI.
chkdsk i : \ dat a / f
CheckfilesindirectorydataondriveI,fixerrors.
chkdsk
Checkcurrentdisk.
Switches:
/D Changecurrentdriveinadditiontochangingcurrentdirectoryfora
drive.
drive: Displaythecurrentdirectoryinthespecifieddrive.
.. Changetotheparentdirectory.
path Changetopath.Dependingontheotherswitches,thiscanbeapathin
thecurrentdirectory,thecurrentdrive,oranewdrive.
none displaythecurrentdriveanddirectory.
IfCommandExtensionsareenabled,CDchangesasfollows:
Revision: 6/8/2012 Page 4 of 18
Copyright 20042012 Susan Dorey Designs
DOS Tools
Thecurrentdirectorystringisconvertedtousethesamecaseastheondisknames.SoCDC:\TEMP
wouldactuallysetthecurrentdirectorytoC:\Tempifthatisthecaseondisk.
CDcommanddoesnottreatspacesasdelimiters,soitispossibletoCDintoasubdirectorynamethat
containsaspacewithoutsurroundingthenamewithquotes.Forexample:
isthesameas:
whichiswhatyouwouldhavetotypeifextensionsweredisabled.
Examples
cd\
Movestothehighestlevel,therootofthedrive.
cd . .
Movesbackonedirectory.Forexample,ifyouarewithinthe
C:\WINDOWS\COMMANDdirectory,thismovestoC:\WINDOWS.
cd wi ndows
Movestothewindowssubdirectoryofcurrentdirectory.
cd\ wi ndows
Firstmovesbacktotherootofthedriveandthenintothewindows
directory.
cd wi ndows\ syst em32
Movestothewindows\system32subdirectoryofthecurrentdirectory.
d:
Changestotheddrive.
MD, to Create a Directory
Syntax
MKDI R [ dr i ve: ] pat h
MD [ dr i ve: ] pat h
Examples
md t est
Theaboveexamplecreatesthetestdirectoryinthedirectoryyouarecurrentlyin.
md f : \ dat a
Createthedatadirectoryonthef:drive.
RM or RMDIR, to Delete Directories
Syntax
SwitchesonlyapplytoWindowsXPand2000.Whentheswitchesarenotused,actsonlyonempty
directories.
source Specifiesthefile(s)tocopy.Iffileordirectorynamehasembedded
spaces,encloseindoublequotes.
destination Specifiesthelocationand/ornameofnewfiles.Iffileordirectoryname
hasembeddedspaces,encloseindoublequotes.
/A Copiesfileswiththearchiveattributeset,doesntchangetheattribute.
/C Continuescopyingeveniferrorsoccur.
/D:date Copiesfileschangedonorafterthespecifieddate.fnodateisgiven,
copiesonlythosefileswhosesourcetimeisnewerthanthedestination
time.DateisinMMDDYYformat.
/E Copiesdirectoriesandsubdirectories,includingemptyones.Sameas/S
/E.Maybeusedtomodify/T.
/EXCLUDE:filename
[+[file2]][+[file3]]
Excludesdirectoriesandfileswithnamesmatchingstrings(oneormore).
Theargumentisthenameofatextfilewhichcontainsthenamesof
directoriesandfilenamestobeexcluded.Seeexamplesbelow.
NewinWindows2000.
Limitations:
filenamescannothavespaces
directorynamecannothavespaces
iffileisnotlocatedinthesamedirectoryasBATfilethataccessesit,
ordirectoryofcommandprompt,usepath
forfilenames,besttostickto8.3format
longfilenamesshouldbeinquotes,e.g.,longfilename.txt
/F Displaysfullsourceanddestinationfilenameswhilecopying.
/H Copieshiddenandsystemfilesalso.
/I Ifdestinationdoesnotexistandcopyingmorethanonefile,assumesthat
destinationmustbeadirectory.
/K Copiesattributes.Normalxcopywillresetreadonlyattributes.
/L Displaysfilesthatwouldbecopied.
/M Copiesfileswiththearchiveattributeset,turnsoffthearchiveattribute.
/N Copyusingthegeneratedshortnames.
/P Promptsyoubeforecreatingeachdestinationfile.
Revision: 6/8/2012 Page 6 of 18
Copyright 20042012 Susan Dorey Designs
DOS Tools
/Q Doesnotdisplayfilenameswhilecopying.
/R Overwritesreadonlyfiles.
/S Copiesdirectoriesandsubdirectoriesexceptemptyones.
/T Createsdirectorystructure,butdoesnotcopyfiles.Doesnotinclude
emptydirectoriesorsubdirectories./T/Eincludesemptydirectoriesand
subdirectories.
/U Updatesthefilesthatalreadyexistindestination.
/V Verifieseachnewfile.
/W Promptsyoutopressakeybeforecopying.
/Y Overwritesexistingfileswithoutprompting.
NewinWindows2000.
/Y Promptsyoubeforeoverwritingexistingfiles.
Ifthedestinationdoesnotexist,XCOPYwillcreateit.WillacceptUNCpathnames.
Examples
xcopy h: \ *. * / s / k / v
TheabovecommandwillcopyeverythinglocatedontheHdrivetothedriveyouarecurrentlyon.Only
nonemptydirectoriesarecopied.Fileattributesarecopiedintact.Eachfileisverified.
Theexclusionfeaturecanbeparticularlyhelpful.
xcopy " c: \ Dat a\ I deas" " c: \ Backup" / c / i / k / q / s / excl ude: backup- excl udes. t xt
xcopy " c: \ Dat a" " c: \ Backup" / excl ude: d: \ mi ne\ backup- excl udes. t xt
Filebackup-excludes.txtcontains:
\ sol st i ce\
. $$$
Thefirstentry,\solstice\,causesthatdirectoryandallfilescontainedwithinittobeexcluded.The
secondentry,.$$$,causesallfilesnamed*.$$$tobeexcluded.Youcanhaveoneormoreentriesinthe
textfile.Theexcludedfilecanbelocatedanywhere,ifnotinthesamedirectoryastheBATfilebeingrun,be
suretoincludeitscompletepath.
Ihavehadtroublewiththe/excludeswitch.Sometimesitworkswithalongfilename,sometimesitdoes
not.Neverunderstoodwhy.
Revision: 6/8/2012 Page 7 of 18
Copyright 20042012 Susan Dorey Designs
DOS Tools
DIR, to List Files
YoucanusetheDIRcommandtocreatealistoffilesinanameddirectoryand,optionally,itssubdirectories;
thelistcanbesavedasatextfileforprintingandlateruse.Thecaptureinatextfileallowsyouto
permanentlyandeasilydocumentfilesinadirectorystructure.
Syntax
DI R [ dr i ve: ] [ pat h] [ f i l ename] [ / P] [ / W] [ / D] [ / A[ [ : ] at t r i but es] ]
[ / O[ [ : ] sor t - or der ] ] [ / T[ [ : ] t i me- f i el d] ] [ / S] [ / B] [ / L] [ / N] [ / X] [ / C]
SwitchesmaybepresetintheDIRCMDenvironmentvariable.Overridepresetswitchesbyprefixingany
switchwith(hyphen)forexample,/W.
SomeswitchesapplytoWindowsNTbutnotWindows98:DTNXC
SomeswitchesapplytoWindows98butnotWindowsNT:V4
[drive:][path][filename] Specifiesdrive,directory,and/orfilestolist.Encloseindoublequotes
whennameshaveembeddedspaces.
/4 Yearsas4digits(ignoredif/Valsoused).
/A Displaysfileswithspecifiedattributes.
Attributevalues:
DDirectoriesRReadonlyfiles
HHiddenfilesAFilesreadyforarchiving
SSystemfilesPrefixmeaningnot
/B Usesbareformat(noheadinginformationorsummary).
/C Displaysthethousandseparatorinfilesizes.Thisisthedefault.Use/C
todisabledisplayofseparator.
/D Listsinwideformatbutfilesarelistsortedbycolumn.
/L Useslowercase,i.e.,changesallnamestolowercase.
/N Newlonglistformatwherefilenamesareonthefarright.
/O Listsbyfilesinsortedorder:.
sortordervalues:
NByname(alphabetic)
SBysize(smallestfirst)
EByextension(alphabetic)
DBydate&time(earliestfirst)
GGroupdirectoriesfirst
Prefixtoreverseorder
/P Pausesaftereachscreenfulofinformation.
/S Displaysfilesinspecifieddirectoryandallsubdirectories.
/T Controlswhichtimefieldisdisplayedorusedforsorting:
timefieldvalues:
CCreation
ALastAccess
WLastWritten
/V Verbosemode.
Revision: 6/8/2012 Page 8 of 18
Copyright 20042012 Susan Dorey Designs
DOS Tools
/W Useswidelistformat.
/X Thisdisplaystheshortnamesgeneratedfornon8dot3filenames.The
formatisthatof/Nwiththeshortnameinsertedbeforethelongname.If
noshortnameispresent,blanksaredisplayedinitsplace.
Examples
Capturecontentsofdirectoryonharddrive,thenprintit:
di r / s / b c: \ dat a\ l ad > c: \ t emp\ di r . t xt
copy c: \ t emp\ di r . t xt l pt 1
Capturecontentsofdirectoryonfileserver:
di r " v: \ knowl edge management " > " c: \ dat a\ di r ect or y l i st s\ KMI Li br ar y Di r . t xt "
Capturecontentsofadirectoryandallsubdirectories,usefullfilenames,groupsubdirectoriesatthe
beginningofthelist,andsortfilesbyname.
di r / B / S / O: G / O: N / T: W" c: \ dat a\ pge 2001\ manual " > " c: \ dat a\ pge
2001\ manual \ di r . t xt "
Capturecontentsofdirectoryonwebsite:
di r " \ \ i know- sps. schwab. com\ si t es\ i s_at _f ms\ The Back Room" / o: n > " h: \ web back
di r ect or y l i st 120506. t xt "
[Inthisexample,thedirectoryisadocumentlibraryonaSharePointsite.]
TREE, to Display Folder Structure
Graphicallydisplaysthefolderstructureofadriveorpath.
/ F
Displaythenamesofthefilesineachfolder.
/ A
UseASCIIinsteadofextendedcharacters.
DEL, to Delete File(s)
Deletesoneormorefilesincurrentdirectory.
namesSpecifiesalistofoneormorefilesordirectories.
Wildcardsmaybeusedtodeletemultiplefiles,e.g.,
DELc:\data\*.*willdeleteallthefileswithinthenameddirectory
DELc:\data\*.wpdwilldeleteallthefileswiththesuffixwpdwithinthenameddirectory
Ifadirectoryisspecified,allfileswithinthedirectorywillbedeleted,e.g.,DELc:\data
/P promptsforconfirmationbeforedeletingeachfile.
/F forcedeletingofreadonlyfiles.
/S deletespecifiedfilesfromallsubdirectories.
Revision: 6/8/2012 Page 9 of 18
Copyright 20042012 Susan Dorey Designs
DOS Tools
/Q Quietmode,donotaskifoktodeleteonglobalwildcard
/A selectsfilestodeletebasedonattributes:
RReadonlyfilesSSystemfiles
HHiddenfilesAFilesreadyforarchiving
Prefixmeaningnot
IfCommandExtensionsareenabledDELandERASEchangeasfollows:Thedisplaysemanticsofthe/S
switcharereversedinthatitshowsyouonlythefilesthataredeleted,nottheonesitcouldnotfind.
REN, to Rename File or Directory
SometimesWindowsExplorerwillnotletyourenameadirectory.Ithasitsexcuses.Makesurethedirectory
isnotinuse,thenusethisDOScommand.Itrenamesfilesordirectoryintheircurrentlocation.
Notethatyoucannotspecifyanewdriveorpathforyourdestinationthatwouldbemovingthe
file/directory.
Examples:
renamec:\datamine Renamethedirectorydatatomine
rename*.txt*.bak Renamealltextfilestofileswith.bakextension
PING, to Verify Network Connection
Verifiesconnectiontooneormoreremotecomputers.AvailableonlyifTCP/IPisinstalled.
Example:
PINGen.wikipedia.org
PING208.80.152.10
PINGsendsasmallpacketthroughthenetworktoaparticularaddress.Thereceivingaddressreturnsa
packetwiththeIPaddressofthereceiver.Ifthereisnoreturnpacket,thedestinationaddressiseithernon
existentorhasnonetworkconnection.Ifthereisareturnpacket,PINGdeterminesthenumberofhops
alongthepathandtheelapsedtime.
Thereareoptionalswitches:
t Pingthespecifiedhostuntilinterrupted.
a Resolveaddressestohostnames.
ncount Numberofechorequeststosend.
lsize Sendbuffersize.
f SetDontFragmentflaginpacket.
iTTL TimeToLive.
Revision: 6/8/2012 Page 10 of 18
Copyright 20042012 Susan Dorey Designs
DOS Tools
vTOS TypeOfService.
rcount Recordrouteforcounthops.
scount Timestampforcounthops.
jhostlist Loosesourceroutealonghostlist.
khostlist Strictsourceroutealonghostlist.
wtimeout Timeoutinmillisecondstowaitforeachreply.
InWindows2000youcanpress[CtrlBreak]whenrunningthetoptionforalistofstatistics.Press[Ctrl+C]
toactuallystoptheping.
Exampleofreturnmessages:
C: \ Document s and Set t i ngs\ Owner >pi ng www. susandor eydesi gns. com
Pi ngi ng susandor eydesi gns. com[ 66. 226. 64. 26] wi t h 32 byt es of dat a:
Repl y f r om66. 226. 64. 26: byt es=32 t i me=23ms TTL=55
Repl y f r om66. 226. 64. 26: byt es=32 t i me=23ms TTL=55
Repl y f r om66. 226. 64. 26: byt es=32 t i me=22ms TTL=55
Repl y f r om66. 226. 64. 26: byt es=32 t i me=22ms TTL=55
Pi ng st at i st i cs f or 66. 226. 64. 26:
Packet s: Sent = 4, Recei ved = 4, Lost = 0 ( 0%l oss) ,
Appr oxi mat e r ound t r i p t i mes i n mi l l i - seconds:
Mi ni mum= 22ms, Maxi mum= 23ms, Aver age = 22ms
TRACERT, to Trace Packet Route Over Network
AkaTRACEROUTE,thisTCP/IPutilityallowsyoutodeterminetheroutepacketstakethroughanetwork
toreachaparticularhostthatyouspecify.Ifusedproperly,TRACERTcanhelpyoufindpointsinyour
networkthatareeitherroutedincorrectlyorarenotexistentatall.
Syntax:
TRACERT [ - d] [ - h maxi mum_hops] [ - j host - l i st ] [ - w t i meout ] t ar get _name
Switches:
d Donotresolveaddressestohostnames.
hmaximum_hops Maximumnumberofhopstosearchfortarget.
jhostlist Loosesourceroutealonghostlist.
wtimeout Waittimeoutmillisecondsforeachreply.
Exampleofresults:
C: \ Document s and Set t i ngs\ Owner >t r acer t 66. 226. 64. 26
Tr aci ng r out e t o pr o25. abac. com[ 66. 226. 64. 26]
over a maxi mumof 30 hops:
1 <1 ms <1 ms <1 ms 192. 168. 1. 1
2 8 ms 9 ms 8 ms adsl - 70- 137- 159- 254. dsl . snf c21. sbcgl obal . net
[ 70
. 137. 159. 254]
3 9 ms 9 ms 8 ms di st 1- vl an52. snf cca. sbcgl obal . net [ 206. 13. 3. 65]
Revision: 6/8/2012 Page 11 of 18
Copyright 20042012 Susan Dorey Designs
DOS Tools
4 9 ms 8 ms 8 ms bb1- 10g2- 0. snf cca. sbcgl obal . net
[ 216. 102. 176. 224
]
5 10 ms 9 ms 9 ms 151. 164. 95. 198
6 10 ms 9 ms 10 ms asn2828- XO. pxpaca. sbcgl obal . net
[ 151. 164. 249. 102
]
7 10 ms 10 ms 10 ms t e- 3- 2- 0. r ar 3. sanj ose- ca. us. xo. net
[ 207. 88. 14. 97
]
8 19 ms 18 ms 24 ms 207. 88. 14. 98. pt r . us. xo. net [ 207. 88. 14. 98]
9 22 ms 22 ms 22 ms 207. 88. 186. 54. pt r . us. xo. net [ 207. 88. 186. 54]
10 25 ms 24 ms 25 ms gi 1- 2. cr 1. sandi ego. abac. net [ 66. 226. 66. 5]
11 23 ms 22 ms 23 ms pr o25. abac. com[ 66. 226. 64. 26]
Tr ace compl et e.
MEM, to View Memory Amount
Displaystheamountofusedandfreememoryinyourcomputer.
Exampleofresult:
/FS:filesystem Thefilesystem:(FATorNTFS.
TheNTFSfilesystemdoesnotfunctiononfloppydisks.
/V:label Thevolumelabel.
/Q Quickformat.
/C Compressionfilesaddedtothenewdiskwillbecompressed.
size Maybedefinedeitherwith/F:sizeor/A:size.
Defaultsettings(via/F)arestronglyrecommendedforgeneraluse.
NTFSsupports512,1024,2048,4096,8192,16K,32K,64K.
FATsupports8192,16K,32K,64K,128K,256K.
NTFScompressionisnotsupportedforallocationunitsabove4096.
/A:size Allocationunitsize.
/F:size sizeisthesizeofthefloppydisk(720,1.2,1.44,2.88,or20.8).
Revision: 6/8/2012 Page 12 of 18
Copyright 20042012 Susan Dorey Designs
DOS Tools
Lookingfortechniquestomonitoruseofports.
NETSTAT, to Monitor Use of Ports
DisplaysprotocolstatisticsandcurrentTCP/IPnetworkconnections.
NETSTAT [ - a] [ - b] [ - e] [ - n] [ - o] [ - p pr ot o] [ - r ] [ - s] [ - v] [ i nt er val ]
aDisplaysallconnectionsandlisteningports.
bDisplaystheexecutableinvolvedincreatingeachconnectionor
listeningport.Insomecaseswellknownexecutableshost
multipleindependentcomponents,andinthesecasesthe
sequenceofcomponentsinvolvedincreatingtheconnection
orlisteningportisdisplayed.Inthiscasetheexecutable
nameisin[]atthebottom,ontopisthecomponentitcalled,
andsoforthuntilTCP/IPwasreached.Notethatthisoption
canbetimeconsumingandwillfailunlessyouhavesufficient
permissions.
eDisplaysEthernetstatistics.Thismaybecombinedwiththes
option.
nDisplaysaddressesandportnumbersinnumericalform.
oDisplaystheowningprocessIDassociatedwitheachconnection.
pprotoShowsconnectionsfortheprotocolspecifiedbyproto;proto
maybeanyof:TCP,UDP,TCPv6,orUDPv6.Ifusedwiththes
optiontodisplayperprotocolstatistics,protomaybeanyof:
IP,IPv6,ICMP,ICMPv6,TCP,TCPv6,UDP,orUDPv6.
rDisplaystheroutingtable.
sDisplaysperprotocolstatistics.Bydefault,statisticsare
shownforIP,IPv6,ICMP,ICMPv6,TCP,TCPv6,UDP,andUDPv6;
thepoptionmaybeusedtospecifyasubsetofthedefault.
vWhenusedinconjunctionwithb,willdisplaysequenceof
componentsinvolvedincreatingtheconnectionorlistening
portforallexecutables.
intervalRedisplaysselectedstatistics,pausingintervalseconds
betweeneachdisplay.PressCTRL+Ctostopredisplaying
statistics.Ifomitted,netstatwillprintthecurrent
configurationinformationonce.
ToviewTCP/UDPportswhichareinusebyagivenprocesswerecommendthefreewareutilityActive
PortsfromSmartLineInc..ThisutilityprovidesarealtimeGUIviewofwhichportsareinusebywhich
processeswhichcanbehandyfortroubleshootingissueslikeportconflictsbetweennetworkenabled
applications.Seehttp://www.devicelock.com/freeware.html.
http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbersisagoodreferenceofthedomainof
portnumbers.
Revision: 6/8/2012 Page 13 of 18
Copyright 20042012 Susan Dorey Designs
DOS Tools
Example 1
Ifyouareonlyinterestedinseeingwhichportsarecurrentlyopen,runningnetstat -afromthecommand
linewilllistthestatusofallportsinuse.Itwillnot,however,tellyouwhichprocessisaccessingthoseports.
Description:Thiscommandlinetooldisplaysalistofapplication(s)andassociatedtask(s)/process(es)
currentlyrunningoneitheralocalorremotesystem.
ParameterList:
/SsystemSpecifiestheremotesystemtoconnectto.
/P[password]Specifiesthepasswordforthegiven
usercontext.Promptsforinputifomitted.
/M[module]ListsalltasksthathaveDLLmodulesloaded
inthemthatmatchthegivenpatternname.
Ifthemodulenameisnotspecified,
displaysallmodulesloadedbyeachtask.
/SVCDisplaysservicesineachprocess.
/VSpecifiesthattheverboseinformation
istobedisplayed.
/FIfilterDisplaysasetoftasksthatmatcha
givencriteriaspecifiedbythefilter.
/FOformatSpecifiestheoutputformat.
Validvalues:TABLE,LIST,CSV.
/NHSpecifiesthattheColumnHeadershould
notbedisplayedintheoutput.
ValidonlyforTABLEandCSVformats.
/?Displaysthishelp/usage.
Filters:
Fi l t er Name Val i d Oper at or s Val i d Val ue( s)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
STATUS eq, ne RUNNI NG | NOT RESPONDI NG
I MAGENAME eq, ne I mage name
PI D eq, ne, gt , l t , ge, l e PI D val ue
SESSI ON eq, ne, gt , l t , ge, l e Sessi on number
SESSI ONNAME eq, ne Sessi on name
CPUTI ME eq, ne, gt , l t , ge, l e CPU t i me i n t he f or mat
of hh: mm: ss.
hh - hour s,
mm- mi nut es, ss - seconds
MEMUSAGE eq, ne, gt , l t , ge, l e Memor y usage i n KB
USERNAME eq, ne User name i n [ domai n\ ] user
f or mat
SERVI CES eq, ne Ser vi ce name
WI NDOWTI TLE eq, ne Wi ndow t i t l e
MODULES eq, ne DLL name
Examples:
TASKLI ST
TASKLI ST / M
Revision: 6/8/2012 Page 17 of 18
Copyright 20042012 Susan Dorey Designs
DOS Tools
TASKLI ST / V
TASKLI ST / SVC
TASKLI ST / M wbem*
TASKLI ST / S syst em/ FO LI ST
TASKLI ST / S syst em/ U domai n\ user name / FO CSV / NH
TASKLI ST / S syst em/ U user name / P passwor d / FO TABLE / NH
TASKLI ST / FI " USERNAME ne NT AUTHORI TY\ SYSTEM" / FI " STATUS eq r unni ng"
C: \ Document s and Set t i ngs\ sdor ey>
Port Usage Advice from Google
Hereisaquickandeasywaytodigintowhatportsarebeingused,andwhatappsareusingthem.
Step1:Findoutwhatportsarebeingused:
C: \ >Net St at o
Whichwillreturnthefollowing(yourlistwillprobablybemuchlonger):
Pr ot o Local Addr ess For ei gn Addr ess St at e PI D
TCP EC968728: 1108 somesi t e. cor p. com: ht t ps ESTABLI SHED 4072
Step2:Seewhichapp(&more)isusingthatport:
C: \ >TaskLi st / FI " PI D eq 4072" / FO LI ST / V
Whichwillreturnthefollowing