1) NOW
Helps to tell you that a script ran and what time it is
example:
NOW "Hello I just wanted to tell you the time."
displays the current time and any message you specify
2) Net Time
Pull the time from one server assume you have a server named SERVERNAME that has a reliable system clock. An example batch file that would run either from the workstation, or get called from or be part of a logon script, would look like this:
NET TIME \\SERVERNAME /SET /YES
3) Choice
A way to provide for limited user imput
choice /c:choices /n /s /t:c,nn text /c = specifies the allowable key to press /n = doesn't display choices and ? at end /s = Treats choice keys as case sensitive /t:c,nn = sets the default to c after nn seconds text = prompt string to display
4) Shutdown
SHUTDOWN /L /R /C /T:xx "Message"
/L = Local sutdown
/R = Reboot after shut down
/C = close all running programs
/T:xx = timer for shut down in seconds
5) If
To create a logon script that will call different batch files depending on the different Operating systems. The following example batch file could be used as a logon script that calls
diferent batch files from the Z mapped share.
If "%OS%" = = "Windows_NT" goto NT_OS
CALL z:\other.bat
EXIT
:NT_OS
CALL NT4.bat
EXIT
6) Known Variables
You can use these variables in your logon script: %Homedrive% The drive letter of the local workstation. %Homepath% The user’s home directory path. %Homeshare% The share name of the user’s home directory. %Os% The workstation operating system. %Processor_architecture% The Processor type (e.g., x86) %Processor_level% The processor lever of the workstation (3, 4 or 5 for an x86). %Userdomain% The user’s Domain. %Username% The user name.
7) Ping
Ping 10.10.10.1 -t = continuously until CTRL + C
ping 10.10.10.1 -n # = # is the number of packets to send
ping 10.10.10.1 -l size = size of packet to send
ping 10.10.10.1 -r count = tell it how many routes to show
8) Net Session
To find out who is connected to the sever
Net session [\\computername] [\delete]
net session /delete /y = Automatically disconnect all users from the server 9) Net Stop and Net Start
A command to stop or start services on the server. It is important that the command
line is written the same way that it is in the server manager (upper,lower case).
net stop "Server" /Y
net stop "Microsoft DHCP Server" /Y
net stop "Windows Internet Name Service" /Y
net start "Server" /y
net start "Microsoft DHCP Server" /Y
net start "Windows Internet Name Service" /Y 10) For Statement
You can use the built-in For command to loop through a list of
files. If you type the command For /f "tokens=*" %a in ('dir /b *.*') do echo %a
the command outputs only the name of each file in the current folder,
which the 'dir /b *.*' component can do all by itself. However, you
can edit the "do" portion of the command to perform a secondary task.
For example, you can add the name of a batch file and the %a parameter
to call the batch file on each .msg file: For /f "tokens=*" %a in ('dir /b *.msg') do datetime.bat %a
In addition to outputting the name of each file in the specified
folder, this command adds the current date and time to the end of each
.msg filename. If you use the command in a batch file, you need to add
two percent (%) signs instead of one to access the parameters. For
example, if you incorporate the above command into a batch file, you
would type it as For /f "tokens=*" %%a in ('dir /b *.msg') do datetime.bat %%a11) Last Commands Typed
-Enter a command or two, then press F7. This lists the last 100 commands you've issued in that console session. Select an item from the list to perform the command again.
-Pressing F3 displays the last command you entered.
-Up Arrow sometimes works too.
12) open a My Computer Window
If you want to open a My Computer GUI window from the command line, simply type: start then hit enter.
The focus of the window is set to the current folder.
13) Output to Text
Send the output of a DOS utility to a file use the ">" operator.
Send the output to a file as follows: netdiag > netdiag.txt
OR send it to the clipboard so you can paste the results some where else.
Windows 2003 & XP have a utility called Clip that you can use (but not Win2K) netdiag | clip14) Create a link to Network Printer
net use lpt1: \\server\PrinterName
OR
rundll32 printui.dll,PrintUIEntry /in /n \\server\printername /y
/y makes printer default
15) Create domain User accounts
Type the following:
NET USER username password /add /domain
username = the name of the user to be added
password = the default password to be assigned to the user
/domain = do NOT put your domain name in here - it assumes the domain you are logged on to
It places the user account in the default USER container
16) List and Manage Services
XP & 2003 Use TASKLIST. (In Windows 2000, use TLIST).
Try TASKLIST /v.
TASKLIST /svc top-level executables and services.
The SC utility is a full replacement for the Services.msc console.
For example, to stop then disable the Browser service, enter:
sc stop browser
sc config browser start= disabled
(In the second line, the space after the "start= " entry is deliberate).
Another powerful tool for managing services is the Windows Management Instrumentation Console (WMIC). To get a quick list of the running processes:
wmic process list brief
To get information from remote servers. For example, from server named W2K3Server1, enter:
wmic /node:W2K3Server1 process list brief
To get a quick list of running services, enter:
wmic /node:W2K3Server1 service where state="running" list brief
To see if the W3SVC (World Wide Web service) is running on a Web server:
wmic /node:W2K3Server1 service where name="w3svc" list full
If the W3SVC service has stopped, use:
wmic /node:W2K3Server1 service where name="w3svc" call startservice 17) List Computer Management Information
try: systeminfo
The "/fo csv" switch tells it to format the output in a single, comma-delimited line systeminfo /fo csv > systeminfo.csv
For example, the following statement loops through each line in a text file called Serverlist.txt, runs Systeminfo to get the statistics for the designated server, and stores the result as individual lines in a comma-delimited file. for /f %i in (c:\serverlist.txt) do systeminfo /s %i /fo csv /nh >> systeminfo.csv
The "f" switch tells FOR to loop through the designated file and assign each line to a variable called "%i." (The letter choice is arbitrary.) The double angle brackets (>>) tell SYSTEMINFO to append each output line to the target file, rather than overwriting the file each time. The result is a spreadsheet that contains a comprehensive set of parameters for every server in the list
To get a file of server names in your network use the NET VIEW command: net view /domain:company > c:\serverlist.txt
NET VIEW simply queries the Browser database, which is not authoritative
To get it out of your AD (all servers need to be in one OU). An example of the Csvde utility that dumps the Common Name (CN) of each object in an OU called Server: csvde -d ou=servers,dc=company,dc=com -l cn -f serverlist.csv 18) Managing Local Network Configuration
Use the Network Shell, or Netsh on Win2K and higher netsh interface ip set address local static 192.168.0.100 255.255.255.0 192.168.0.254 0
The sequence of numbers in the expression is "Address, Mask, Gateway and Interface Metric." The word "local" refers to the first word of the default network interface name, "Local Area Connection." If you have two or more network interfaces, you'll need to spell out the entire name.
To change the DNS and WINS configuration type: netsh interface ip set dns local static 192.168.0.1 netsh interface ip set wins local static 192.168.0.5 19) NetDiag (only on 2000 & 2003 server)
NetDiag is a powerful diagnostic tool that helps identify network and connectivity issues
NetDiag is run in command mode with the command NetDiag
It performs a variety of tests to determine the state of your network client
Can fix ADS & DNS Q21928920) PathPing (only on 2000 & 2003 server)
PathPing combines the best of Ping and Tracert, plus adds
new features Run PathPing in command mode to see the results Q24460221) Compact /c /u /s :Directory /a /i /F /Q filename
The following compactes a file or folder on an NTFS drive /c = compress the specified file or directory /u = uncompress the specified file or directory /s = do it on this directory and all subdirectory /a = Displays Hidden or System files /i = Ignores any errors that may occur and continues /f = compress all files and skip the ones already compressed /Q = reports only most essential information filename or directory to be compressed but not subs 22) NBTSTAT [-a RemoteName] [-A IP address] [-c] [-n]
[-r] [-R] [-RR] [-s] [-S] [interval] ]
Displays protocol statistics and current TCP/IP connections using NBT
(NetBIOS over TCP/IP)
-a (adapter status) Lists the remote machine's name table given its name -A (Adapter status) Lists the remote machine's name table given its IP address -c (cache) Lists the global remote name cache including the IP addresses -C (cache) Lists the remote name cache with IP addresses on a per-device basis -n (names) Lists local NetBIOS names -r (resolved) Lists names resolved by broadcast and via WINS -R (Reload) Purges and reloads the remote cache name table -S (Sessions) Lists sessions table with the destination IP addresses -s (sessions) Lists sessions table converting destination IP addresses to host names via the hosts file -RR (ReleaseRefresh) Sends Name Release packets to WINs and then, starts Refresh RemoteName Remote host machine name IP address Dotted decimal representation of the IP address interval Redisplays selected statistics, pausing interval seconds between each display. Press Ctrl+C to stop redisplaying statistics 23) File and Directory Name Completion in DOS
It's a feature that can speed up your navigation when you use the command prompt.
You can enable this feature by starting a command prompt with the /f:on switch.
Use the run command or create a short cut on your desktop
If your at the command prompt at the root of C: and you want to go to the Windows Folder
Type "W" then press CTRL+F, the rest of the characters are filled in for you.
If you don't know the exact name of a folder to use this technique.
Hold down the CTRL key and keep on clicking D (or F),
you will cycle through all the possible folders. Back To Main Page