Vous êtes sur la page 1sur 27

LAB A

COMMAND
PROMPT &
INSTALLING WIN
7
Download this Lab instruction file for this class from Blackboard under assignments.
Save your Lab worksheet to your USB drive. When your assignment is complete,
you must submit the Lab worksheet to Blackboard under Project Submission by the
due date listed on your syllabus for full credit.

The steps in this lab are NOT in the textbook or in the


Lab manual.
Exercise
1a Navigating in the Command Prompt
Overview In this exercise, you will learn some of the basics of navigating in a
command prompt. You will learn to create, delete and modify
directories and view information about files and directories.

The command prompt can be a powerful way of managing and using


the file structure in a computer. You can use directory commands to
manage and see the same information that you do with the Windows
Explorer.

Complete this activity on the HOST in the classroom. (It can also be completed on a
windows computer at home)

Completion time 50 minutes

The steps in this lab are NOT in the textbook or in the Lab manual.
Vocabulary
File Block of information stored on a computer. It must have a unique name
within a folder.

Folder A collection of related files used to help organize the file system

Directory Same as folder

Subdirector A folder (directory) inside of another folder (directory)


y

1. Click on Start, in the search box, type in cmd and press <Enter>. A window will
open like the printscreen below.

2. Take a look at what you see on the screen currently. On the lab computer, the
default directory is C:\Users\student (your computer may have a different default
directory.)
cd

3. The cd command allows you to change directories.


4. When you are using the command prompt everything must be spelled correctly
or a command will not work. Spaces are important too. If you have extra spaces or
are missing spaces, you may not get the results that you are looking for.
5. Type cd\windows\system32 and press <Enter>. This will change your current
directory to the c:\windows\system32 directory.
6. You can traverse to a folder inside of the current directory by typing cd <space>
folder. This will change to a subdirectory immediately inside of the current directory.
Try this by typing cd speech and press <Enter>. Notice how the current directory
displayed is now the c:\windows\system32\speech directory.
7. Now type in cd\ and press <Enter>
8. This changes you to the root directory. The root directory is very important for
you to be familiar with. The root is considered to be the beginning of the drive.
9. You can change to a directory 1 folder at a time OR you can change to directories
with 1 command.
a. Type in cd windows and press <Enter>
b. Type in cd system32 and press <Enter>
c. Type in cd speech and press <Enter>
Steps when you start at the root of the drive, steps a-c above are the same as d
below.
d. To make the directory change with 1 command, type in
cd\windows\system32\speech and press <Enter>
10. Try both of the above directory changes.
11. After changing to the c:\windows\system32\speech directory, to move back 1
folder, type in cd .. and press <Enter> (see the picture below)

dir

12. Now we will look at the files within a directory.


13. Type in cd\users\student and press <Enter>. Then type in dir and press
<Enter> (My results are below, your results may be different than mine. Also, this
assumes that you are on the computers on campus. If you are in another location,
type cd\users then type dir to see the usernames listed and then type cd
yourusername.)
14. This is showing us the files and folders that are in the current directory of
C:\Users\student
15. You can see the same files and folder information with the Windows Explorer.
Click on Start, then Computer,
16. Double click on the C drive, Double click on the Users folder, then double click
on student

17. You can see the same folders in the command prompt that you can see in the
Windows Explorer. (NOTE: the AppData folder and the
ntuser.dat.LOG1 & 2 files are hidden. The HOST
computer is configured to see hidden files, so they are
displayed in the Windows explorer.)
help screens for command line utilities

18. The dir command can do more than just display a list of files and folders. There
are switches that you can use with the command to see the information in a
different way. To get help for most command line utilities, type in the command,
then /? after the command. In the command prompt, type in dir /? and press
<Enter>, then read the help screen.
Ex 1a List 3 ways you can sort a directory listing? by name, size, and date/time
Question
1

19. Change to the c:\windows\system32 directory and then compare the next 2
directory listings.
a. Type dir /o:d and press <Enter>
b. Type dir /o:-d and press <Enter>
Ex 1a
Explain how the 2 directory listings are different? second is in reverse
Question
order
2
Ex 1a
What are the results when you do a directory listing with the /p switch?
Question
stop information each time screen is full
3
Ex 1a What are the results when you do a directory listing with the /s switch?
Question display files in specifide directory and all subdirectories
4
Ex 1a
Question Are Command Line Utilities in DOS case sensitive? no
5
Ex 1a
Question What is the wildcard that can be used to replace 1 character? ?
6

Repeat commands

20. The computer remembers several of the previous commands. To see the
previous command, you can press the <up arrow>. Each time you press the <up
arrow>, you can see the previous command. To change the command, you can
then press the <left arrow> and insert or delete text from the command.
21. Try pressing the <up arrow> now. You should see the dir /o:-d command.
Redirect output to a file

22. Sometimes it is helpful to get a directory listing into a document. You can take
the output that is displayed on the screen and redirect it into a file on your
computer. Then you could copy and paste that information to a document.
23. Start in the c:\users\student directory. (NOTE: if you are on a different computer,
you need to change this to the directory for the user that you are currently logged
in as. If you are unsure, change to the users folder first, then do a directory listing,
then change to the directory that corresponds with the name you are logged in as.)
24. Type dir and press <Enter> to view the contents of this folder on the computer
screen.
25. To redirect the output from the computer screen to, use the greater than symbol.
Type dir > list.txt and press <Enter>. This will create a file called “list.txt”. The
file will be located in the current directory which is c:\windows. (See the printscreen
below for help)

26. Now run a directory listing again. You should see a new file, list.txt, in your
directory listing.
27. To view the file, type in notepad list.txt and press <Enter>
28. The notepad program should open up a text document that contains the results
of the list.txt document.
29. Take a screen shot of the notepad program with the list.txt file open, and then
paste it below by pressing Ctrl+V.
PastePrintscreenHere
30. Close out of the notepad program.
31. You can redirect any output from other commands in the command prompt by
using the redirect.
Copy or paste text inside of a command prompt

32. Sometimes you want to copy and paste text, such as a filename from inside of a
command prompt .
33. On the far left of the command prompt window’s title bar, click the Command
Prompt icon. (See the red circle in the picture below)

34. From the menu, click on Edit and then Mark. A blinking cursor then appears at
the top of the command prompt window.
35. Click and drag the cursor over the text you would like to copy to the clipboard;
the information will be highlighted. For this lab, I would like you to highlight the line
that contains the list.txt file that you created in the redirect portion of this lab. See
the printscreen below. (If you can’t see it at this time, from the c:\users\student
folder run a directory listing again. )

36. After you have highlighted all the information you want to copy, press <Enter>
This will place the highlighted text into the clipboard.
Ex 1a
Question Paste the text you copied above in this box? TypeAnswerHere
7
Creating, deleting and copying directories and files

37. From the command prompt, type cd\ and press <Enter>. This should change us
to the root of the drive.
38. To make a new directory called new, type md new and press <Enter> (NOTE:
this will create the new directory in the current directory which is the root of the
drive)
39. Create these other directories using the md command.
i. c:\new\software
ii. c:\new\stuff
iii. c:\new\class
iv. c:\new\class\assignments
v. c:\new\class\letters
40. Change to the c:\new directory
41. Use the cd command to change directories and see what you have created.
42. If you make a mistake, you can delete a directory by using the rd command.
43. For example, to delete the c:\new\class\letters directory, you can type rd
c:\new\class\letters and press <Enter> (NOTE: this will keep the folder,
c:\new\class and remove only the letters folder. The folder must be empty in order
to delete it.)
44. If you deleted the c:\new\class\letters folder, please create the folder again now.
45. Change to the c:\new\class\assignments directory
46. Type notepad lab.txt and press <Enter>. Click Yes to create a new file. Type
in any text in the file then close and save the notepad program.
47. Type copy lab.txt c:\new\stuff and press <Enter> (this should keep the lab.txt
file in the c:\new\class\assignments AND put another copy of the same file in
c:\new\stuff)
48. Change to the c:\new folder, then type dir /s > new.txt and press <Enter>
49. Type notepad new.txt and press <Enter>
50. Copy the entire contents of the new.txt file from notepad and paste it into this
document here:
PasteContentsHere
51. Close out of the notepad program.

USE YOUR LAB


MANUAL ALONG
WITH THESE
DIRECTIONS TO
COMPLETE THE
REMAINING
LABS.
Follow the steps for each exercise in your “Windows 7 Configuration Lab
Manual”. The steps listed below are the changes from the steps in the printed lab
manual. You must complete ALL Exercises, Lab Review questions, and Lab Challenge
Exercises that are listed in this lab worksheet.

Exercise 1.1 Running Upgrade Advisor


Overview In Exercise 1.1, you run the Windows 7 Upgrade
Advisor program on the HOST computer to determine
whether it is capable of running Windows 7.

Complete this activity on the HOST machine in the classroom. The “Upgrade
Advisor” is should be downloaded to c:\dl on the HOST machine. If it is not, you
can download it from Blackboard. You may also need to install the .NET Framework.
Feel free to do this on the lab machines (they are refreshed when you reboot the
HOST computer)

Completion time 20 minutes

Complete this lab on the HOST pc in class (Not your VM)


Skip steps 1-7 in the book
Ex 1.1 According to Upgrade Advisor, is your workstation capable of running
Question Windows 7? Yes
1
Ex 1.1
Is your workstation capable of running Windows Aero? If not, why not?
Question
Yes
2

Ex 1.1 Are there any devices in the computer for which Upgrade Advisor could
Question not find information? Yes If so, which ones? PCI Serial Port PCI Simple
3 Communications Controller

Ex 1.1
Are there any applications (programs) on the computer that might cause
Question
compatibility issues with Windows 7? No
4

12. Take a screen shot of the page that shows the report when you run Windows
7 Upgrade Advisor, and then paste it below by pressing Ctrl+V.

PastePrintscreenHere
Skip Exercise 1.2

LAB 3
INSTALLING
WINDOWS 7
Exercise 3.1 Installing Windows 7 from a DVD
Overview In Exercise 3.1, you install Windows 7 on a workstation,
using a standard installation DVD.

Complete in a new VM. Do this during class with your instructor.


Completion time 50 minutes

NOTE: You will complete this lab DURING class. Do NOT


complete this on your own. The InstallationNotes.doc in
Blackboard under Course Documents will assist you with
the install.
Ex 3.1 What types of partitions did the system create? Divided
Question
1 The system created a 100 MB System Reserved partition, and the
larger partition is a Primary partition.

LAB 7
CONFIGURING
NETWORK
CONNECTIONS
Before starting Lab 7 in the Lab manual, we need to set
up network adapters in VMware so that they will connect
to the RWDC01 server. At this time, it will disable
internet connectivity for our VM.
1. Open VMware(but do not start up your VM). Select your NYC-CLa VM.
Click on VM, Settings, highlight the current Network Adapter

2. On the right side of the page, select Custom VMNet2 (This network
adapter will allow your VM to connect to the RWDC01 server.)

3. When it boots up, the network adapter will take a few minutes to configure.
Click on Work.

Exercise 3.2 Joining a Workstation to a Domain


Overview In Exercise 3.2, you join your newly installed Windows 7
workstation to your network’s Active Directory Domain
Services domain.
Complete this on the VM you created NYC-CLa. BEFORE starting this lab, turn on
the WinServer2008_RWDC01 VM that you downloaded from the Z drive.
Completion time 5 minutes

NOTE: Turn on your Win 2008 server RWDC01 before


starting this lab.
1. After turning on your Win 2008 server, start up the VM of Win 7 (NYC-CLa)
that you just installed. Complete the steps listed in the lab manual on
NYC-CLa.

6. After following step 6 in the lab manual, if you do not get a message box
welcoming you to the contoso domain, please see your instructor. They
will help you troubleshoot the domain issues.

7. Take a screen shot of the message box by pressing Alt+Prt Scr and paste
it into your below by pressing Ctrl+V.

PastePrintscreenHere

Exercise 7.1 Using the Network and Sharing Center


Overview On a Windows 7 computer, the Network and Sharing Center
provides access to most of the operating system’s
networking tools and configuration parameters. In Exercise
7.1, you examine the current Sharing and Discovery
settings on one of the computers that will become part of
the lab network.

Complete this on the VM you created NYC-CLa. BEFORE starting this lab, turn on
the WinServer2008_RWDC01 VM that you downloaded from the Z drive.
Completion time 10 minutes

NOTE: Turn on your Win 2008 server RWDC01 before


starting this lab.
Ex 7.1
Why did the network map fail to appear?
Question
1 the network is public

Ex 7.1 Could the current state of the advanced sharing settings be the
Question reason why the network map fails to appear?
2
yes
Exercise 7.2 Enabling Network Map
Overview In Exercise 7.2, you use local Group Policy to enable
Network Map to display a diagram of the network, so you
can plan the software deployments for the lab network at a
later time.
Complete this on the VM you created NYC-CLa, NYC-CLb, and
WinServer2008_RWDC01
Completion time 10 minutes

12.Take a screen shot of the Network Map window by pressing Alt+Prt Scr,
and then paste the resulting image below by pressing Ctrl+V.

PastePrintscreenHere

Ex 7.2
Why does the RWDC01 computer not appear on the Network Map display?
Question
3 Because it is not set up to be on the same netwrok

Exercise 7.3 Manually Configuring TCP/IP


Overview Because the lab network you are constructing for Contoso,
Ltd. must be isolated from the production network, you do
not want the lab computers to obtain their TCP/IP settings
from the DHCP servers on the production network.
Therefore, in Exercise 7.3 you manually configure the
TCP/IP client to use static IP addresses.
Complete this on the VM you created NYC-CLa, NYC-CLb, and
WinServer2008_RWDC01
Completion time 15 minutes

3. Using the information in the Ipconfig.exe display, note your


workstation’s current TCP/IP configuration settings in Table 7-4.

Table 7-4
TCP/IP Setting Value
IPv4 Address 10.10.0.112
Subnet Mask 255.0.0.0
Default Gateway 10.10.0.2
DNS Servers 10.10.0.2

Ex 7.3
How did the computer obtain these settings? How can you determine this?
Question
4 these are the defalt setting when the coputer cannot find a network

Ex 7.3
What is the result of this command?
Question
5 release the ipconfig for a specific adaptor

Which of the parameters in the Internet Protocol Version 4 (TCP/IPv4)


Ex 7.3
Properties sheet would you have to omit for your computer to be unable
Question
to resolve a computer name into its IP address?
6
You would have to omit the Preferred DNS Server parameter.

12.Take a screen shot of the Internet Protocol Version 4 (TCP/IPv4)


Properties sheet by pressing Alt+Prt Scr, and then paste the resulting
image below by pressing Ctrl+V.

PastePrintscreenHere

How does the Ipconfig display differ from the first time you ran the
Ex 7.3 ipconfig /all command?
Question
7 Except for the IP address, the TCP/IP settings are the same as they were in
the first instance, but the display now shows that DHCP is not enabled and
does not specify a DHCP server address.

Exercise 7.4 Testing Network Connections


Overview After manually configuring the Windows 7 TCP/IP client, you
must test it by trying to connect to the other computers on
the network. In Exercise 7.4, you use the Ping utility to test
the computer’s communications capabilities.
Complete this on the VM you created NYC-CLa, NYC-CLb, and
WinServer2008_RWDC01
Completion time 10 minutes
Ex 7.4
What is the result?
Question
8 The computer successfully pings the specified address.

Ex 7.4 What does this result prove about the computer’s network connectivity?
Question
9 it proves nothing. Pinging the loopback address (127.0.0.1) proves only
that the computer’s TCP/IP client is configured correctly.
What would be the result if you unplugged your computer’s network cable
Ex 7.4 before executing the ping 127.0.0.1 command?
Question
10 The ping test would still be successful because pinging the loopback
address only tests the validity of the computer’s TCP/IP configuration. No
packets actually leave the computer during the loopback test.
Ex 7.4 What is the result of the ping test, and what does it prove?
Question
11 an ARP request and a responce from the server this proves they are both
on the same network
Ex 7.4
What is the IP address of RWDC01?
Question
12 10.10.0.2

How was the computer able to resolve the name RWDC01 into its IP
Ex 7.4
address?
Question
13 The computer sent a name resolution request to the DNS server it is
configured to use.
Ex 7.4
What was the result of the test, and what does this result prove?
Question
14 ping of an ip address proves your on a seperated network

Ex 7.4
What was the result of the test, and what does this result prove?
Question
15 succesful ping and your both connected to the network

Ex 7.4 Was it necessary to perform this last test? Why or why not?
Question
13 no because you have already set the nework up your self and know you
put them on the same network

ADDED STEPS – return your network adapter


configuration to obtain address from DHCP on both NYC-
CLa & NYC-CLb
1. Click on Start, Control Panel, Network and Internet, Network and Sharing
Center, Manage Network Connections, Right click on Local Area Connection
and click on Properties, continue. Highlight Internet Protocol v4 (TCP/IP v4)
and click on Properties.
2. Select Obtain an IP address automatically and select Obtain DNA server
address automatically and then click on OK.

MORE COMMAND
PROMPT AND
BATCH FILES
Exercise N Networking Command Line Utilities (5 pts)
Overview In this exercise, you will explore the use networking and other useful
utilities to expand your knowledge using the command prompt.

Complete this activity on the HOST machine in the classroom (Your VM does not
have internet connectivity at this time..

The steps in this lab are NOT in the textbook or in the Lab manual.

Completion time 40 minutes

The steps in this lab are NOT in the textbook or in the Lab manual.

Run command prompt as administrator

3. Several of the utilities used for networking in the command prompt require
administrative privileges. to use. Click on Start, in the search box, type in cmd.
When the command prompt is listed under programs, then Right Click on the
command prompt and click on Run as administrator.
ipconfig

4. You used the ipconfig command already this semester to display IP address
information. The utility gathers information from the network interface card(s) on
your computer. It also gathers some information from the host machine that your
computer connects with.
5. At the command prompt, enter ipconfig and press <Enter>. The screen will
show the return IP address information. (NOTE: you may have to use the scroll bar
on the right of the command prompt window to scroll up and see some pertinent
information.
6. To get more detailed IP address information, type in ipconfig /all and press
<Enter>
7. You can see additional information about whether the address is obtained
automatically (from DHCP), the lease dates, Physical Address (MAC address)
information and DNS servers.
Ex N
What computer are you using? M103-C13 Is the address on your computer
Question
obtained from DHCP? Yes
1

8. To get help for the ipconfig command, type in ipconfig /? and press <Enter>.
Review the help screens.
NOTE: The next few steps will only work on a network that is configured with DHCP.
If you are at home or somewhere else where the address is statically assigned, you
will need to skip this section and come back to campus to complete it.

9. To terminate an IP address, type in ipconfig /release and press <Enter>.

NOTE: If you get the message above. You need to open your command prompt with
administrative privileges. Follow the steps to “Run command prompt as
administrator”, then repeat step 8.

10. You should see that all DHCP IP addresses are cleared out or blank.
11. To re-establish your IP address, type ipconfig /renew and press <Enter>. When
you renew, sometimes you get the same IP address and sometimes you get a
different IP address.
Ex N
Question What is your default gateway? 172.19.103.254
2

ping

12. The ping utility uses an ICMP (Internet Control Message Protocol) ECHO
request/reply feature to see if the device is reachable on the IP network. It sends
packets across the network to a destination device that you specify. It will measure
the time that it takes for a request to and back from the device. Administrators use
it as a quick way to determine if the connection to the other piece of equipment
that they are trying to connect to is reachable.
13. Sometimes you can connect to a device, but you cannot ping the device. For
this lab, if you get the response Request timed out, just try another site. If you
get it for all sites you try, then make sure that you have an IP address assigned
using the ipconfig command.
14. Type ping www.matcmadison.edu and press <Enter>
15. There are 2 different ways that you can type in the device that you are trying to
ping. Ping IPaddress OR ping hostname. For the hostname, you can use some sites
such as: www.google.com, www.yahoo.com, www.matcmadison.edu. To use the IP
Address, type in the IP address that you are trying to ping.
16. Use ping to measure the round-trip times to the default gateway of your
computer and to 2 other devices/sites.
Device/site to ping Round Trip Round Trip Round Trip
Minimum Time Maximum Average Time
Expect different results from (ms) Time(ms) (ms)
students

1)default gateway 0ms 2ms 0ms


172.19.103.254

2) www.yahoo.com 44ms 54ms 47ms

3) www.google.com 31ms 66ms 52ms

Ex N
Question What is the default size packet for ping? 32 bytes
3

17. Type ping /? To get some help.


18. To change the size of the packet that you are testing, type in ping –l 200
www.matcmadison.edu and press <Enter>. Test some other packet sizes to the
same destinations above, and then answer the question below.
Ex N
When you have a larger packet size, is the ping average response slower
Question
or faster? slower
4

tracert

19. Now you will run a tracert (traceroute) to see the route that the IP packets take
from your computer to a destination on the internet.
20. You can run a tracert on either an IPaddress OR hostname.
21. Type tracert www.matcmadison.edu and press <Enter>
22. Use tracert to measure the number of hops for the 2 other devices/sites that you
tested in the ping section of this lab.
Device/site to tracert Number of hops

1) M103-C13 14 Hops

2) TypeAnswerHere TypeAnswerHere

Ex N Compare the average round trip times for ping and the number of hops
Question for tracert for the 3 devices that are not your gateway. Do you see a
5 relationship between longer delay and higher hop count? TypeAnswerHere

nslookup

23. Now you will run a nslookup command to get the IP Address(es) of a hostname.
24. Type nslookup www.matcmadison.edu and press <Enter>. This will give you
the IP Address of the www.matcmadison.edu host.
25. The first 2 lines are about the name server that is giving the response. The next
2 lines are about the host machine that you are looking up.
26. Use nslookup to obtain the IP Addresses for the 2 other devices/sites that you
tested in the ping section of this lab.
Site/domain IP Address (there may be more than 1 address listed)

1) www.yahoo.com 209.191.93.52 & 69.147.76.15

2) www.google.com 74.125.95.105 & 74.125.95.106 & 74.125.95.147 &


74.125.95.99 & 74.125.95.103 & 74.125.95.104

netsh

27. Now you will run a netsh command to assign an IP address from the command
prompt.
28. So that we are sure to assign an IP address that will work for the computer you
are using now, run a netsh command to document before we start changing the
configuration.
29. Type in netsh interface ip show config and press <Enter>. Then document
the information listed below. (The printscreen below shows the results on the open
lab computer used in this example.)
Example for below to help Your configuration
understand the commands below

Interface Local Area Connection Local Area Connection


name

IP Address 172.19.103.4 172.19.103.5

Subnet Mask 172.19.103.0/24 (mask 172.19.103.0/24


255.255.255.0) (255.255.255.0)

Default 172.19.103.254 172.19.103.254


Gateway

DNS Server 172.18.0.13 172.18.0.13


30. The netsh command can be both a command line utility and an interactive
command. Start the interactive command mode by typing netsh and pressing
<Enter>.
31. Type ? and press <Enter> to see the help information. (NOTE: Read the
commands that are available for netsh. Please note that we will only look at a few
commands. You may use this command more extensively in future classes.)
32. To enter the interface context where you can make changes to the IP Address
type interface and pressing <Enter>.
33. From the netsh interface> prompt, type ? and press <Enter> again. (NOTE: This
will give you additional commands that you can run in the interface context of the
netsh command.)
34. Type in ip set address “Interface Name From Table Above” static
IpAddressFromTableAbove SubnetMaskFromTableAbove
DefaultGatewayFromTableAbove
35. An example using my IP Address info from the table above is: ip set address
“Local Area Connection” static 172.19.103.4 255.255.255.0
172.19.103.254 and press <Enter>.
36. When you change an IP Address, you might also need to change the IP Address
of the DNS server.
37. While you are still in the netsh interface> context, , type ip set dns “Interface
Name From Table Above” static DNSServeAddressFromTableAbove and
press <Enter>
38. Example using above settings: ip set dns “Local Area Connection” static
172.18.0.13 and press <Enter>.
39. Take a screen shot of the netsh interface> context after typing the command to
change the dns server by pressing Alt+Prt Scr, and then paste it below by pressing
Ctrl+V.
PastePrintscreenHere

40. Click on Start, Control Panel, Network and Internet, Network and Sharing
Center, Manage Network Connections, Right click on Local Area Connection
and click on Properties, continue. Highlight Internet Protocol v4 (TCP/IP v4)
and click on Properties. You should see that the IP Address is now statically
assigned and contains the values that you configured above.
41. Take a screen shot of the Internet Protocol Version 4 (TCP/IPv4) Properties by
pressing Alt+Prt Scr, and then paste it below by pressing Ctrl+V.
PastePrintscreenHere

42. Close out of the network connections and properties windows.


43. Open up another command prompt and run ipconfig /all to see the setting
change. The most noticeable change should be that DHCP is NOT enabled and
there is not a lease for the IP Address.
44. To change the IP Address back to a DHCP assigned address, from the netsh
interface> context type ip set address “interface name from table above”
dhcp and press <Enter>
45. An example using my IP Address info from the table above is: ip set address
“Local Area Connection” dhcp and press <Enter>.
46. To change the IP Address of the DNS server, make sure you are still in the netsh
interface> context, , type ip set dns “Interface Name From Table Above”
dhcp and press <Enter>
47. Example using above settings: ip set dns “Local Area Connection” dhcp
and press <Enter>.
48. When you are finished making changes using the netsh command, type exit and
press <Enter>.

Exercise
M Batch Files
Overview In this exercise, you will combine together a few command line
utilities to create a batch file. Batch files are used by administrators
to execute a list of commands sequentially on a computer. They are
often put into scripts so that they will run automatically when a user
logs into a computer so that settings can be changed or
documented. Batch files help to automate a list of commands that
needs to be run on several computers.

Complete this activity on the HOST machine in the classroom (Your VM does not
have internet connectivity at this time..

The steps in this lab are NOT in the textbook or in the Lab manual.

Completion time 40 minutes

An example batch file

1. Before looking at a batch file example, there are some tips that could be helpful.

a. Use a test folder to try out your commands in (so you don’t mess up the
actual data).

b. Batch files have a file extension of .bat Try to name a batch file something
unique, but meaningful. I could make a batch file that displays the letters
of the alphabet and call it alphabet.bat . To run the alphabet.bat batch
file, I need to change to the directory where alphabet.bat is stored and
type alphabet and press <Enter>.

c. Edit batch files in notepad. (DO NOT USE WORD or WORKS or


WORDPERFECT)
d. Pause – the pause command is helpful in creating a batch file because it
will temporarily stop the processing of the batch file so that you can see
each step run. When I start creating a batch file, I sometimes type pause
for every other line so that it will stop often & I can see the results on the
screen slowly.

e. Comment – make sure that you type in comments about what a batch file
purpose is and what each line is doing in your batch files. To comment an
entire line, you can type REM or :: (double colon) as the first characters in
the line.

f. The TYPE command will type the words following it on the screen.

g. When debugging your batch file, make only 1 change at a time.

h. If your batch file hangs, you can stop it by pressing <Ctrl-C>

i. If you create a folder in a batch file and have to run the batch file again, it
will give you an error that it already exists. When testing, delete the
results from the first test before testing again.

j. Wildcard characters

i. * is a substitute for all possible characters. For example: b*.* is for


all files that start with the letter b and have any character after it.

ii. ? is a substitute for 1 character.

k. @ECHO OFF -usually placed at the beginning of a batch file so that


when you run the batch files, you cannot see all of the commands on the
screen. (NOTE: many people comment out this line so they see the
commands show up on the screen while working on their batch files, then
uncomment it when they are finished. This helps with troubleshooting.)

2. There is a sample batch file below. Before you test and work with the sample
file, I want you to create a place to work with the files. Go to the command prompt.

3. Type in md c:\lab and press <Enter>

4. Type in cd c:\lab and press <Enter>

5. Type notepad CopyFiles.bat and press <Enter>. Click on Yes to create a new
file. (NOTE: this will create a new file called copyfiles.bat in the current directory and
open it with notepad.)
6. Copy the text between the lines below and paste them into the copyfiles.bat file
inside of notepad.

@ECHO OFF

REM CopyFiles.bat
REM
REM Creates a test directory and copies files starting with t into it

md c:\lab\test
cd c:\lab\test
REM creates a directory called c:\lab\test, then changes to that directory

copy c:\windows\t*.* c:\lab\test


REM copies files that start with the letter t from the windows folder to the
c:\lab\test folder

dir c:\lab\test > c:\lab\test\dirlist.txt


REM runs a directory listing then redirects the output to a file named
c:\lab\test\dirlist.txt

ECHO copyfiles.bat has finished

7. Close out of notepad and save the changes.


8. You should still be in the c:\lab directory. Type copyfiles and press <Enter>.
This should run the batch file.
9. Browse the directories while looking at the commands above and see if the
results make sense. You will need to understand what each line of code is doing in
order to be able to create your own batch file.
Creating your own batch file

10. Create a directory called c:\mybat


11. Change to the directory c:\mybat
12. Type notepad mybat.bat and press <Enter>. Click on Yes to create a new file.
13. Between the lines below is a list of commands/statements that need to be
included in your batch file.

· Show the text on the screen “MyBat.bat has started. It may take a minute to
complete. Please be patient.”
· Make a directory c:\mybat\test
· Change to the directory c:\mybat\test
· Document the IP Address configuration from the ipconfig command (make
sure that you can see all details) and redirect the output to a file named
c:\mybat\test\IPAddr.txt
· Run a traceroute to the host www.matcmadison.edu and redirect the output
to a file named c:\mybat\test\trace.txt
· Show the text on the screen “MyBat.bat has completed”
14. Close out of notepad and save the changes.
15. You should still be in the c:\mybat directory. Type mybat and press <Enter>.
This should run the batch file.
16. Look at the results of your mybat.bat batch file. If there is something that isn’t
working, edit the mybat.bat file with notepad and make changes and try to run
again. Before you run it again, delete the c:\mybat\test directory and all files inside
of it.
17. Make sure that you try some lines in the command prompt before typing them
into the batch file. In this lab, you learned how to copy and paste from the
command prompt to the clipboard. You could use this as a way to get the exact
command that you typed that worked into the batch file so that everything is
spelled correctly.
18. Don’t forget to put comments into your file. You will not get all of the points if
comments are missing even if the batch file works.
19. Copy the entire contents of the mybat.bat file from notepad and paste it into
this document here:
PasteContentsHere
20. After your batch file works, run a directory listing of the c:\mybat\test folder.
21. Take a screen shot of the directory listing by pressing Alt+Prt Scr, and then paste
it below by pressing Ctrl+V.
PastePrintscreenHere

Make snapshot of VM

Close out of your VM.

Click on VM, Snapshot and Take Snapshot…

Type in the name: After LabA with a description of LabA activities complete &
click on OK.

Submit assignment to blackboard

When your assignment is complete, you must submit the LabA (this file) to
Blackboard under Project Submission by the due date listed on your syllabus for full
credit.
After you have submitted, from inside blackboard, click on Tools, My Grades

Submitted, but not graded

NOT submitted. This shows that either your computer locked up or you lost

connection to the internet OR you clicked on Save instead of Submit. Your


instructor can clear this indicator if you email them.

Vous aimerez peut-être aussi