How to Install File & Printer Sharing from Command Line
Although most users are only familiar with the graphical Windows interface, there is a way to control your computer through the command line. This is useful, for instance, if you want to write login or batch scripts to automate processes. Installing file and printer sharing from the command line is a quick and simple way to let computers on networks share resources.
Things You'll Need
- Computer running Microsoft 98, 2000, XP or Vista
- Local area network
- Shared printer
Instructions
-
Installing File Sharing
-
1
Log into the machine where the files you want to share are located.
-
2
Locate the directory that you want to share across the network. In this example, we'll use the directory "c:\Documents."
-
-
3
Open up a command prompt. Go to "Start-->Run." In the "Run" box, type "cmd.exe" (no quotes). In Vista, go to "Start" and enter "cmd.exe" into the "Start Search" box.
-
4
Pick a name for your shared directory. In this example, we'll call it "SharedDocuments."
-
5
Type in "net share SharedDocuments=c:\Documents" at the command prompt.
-
6
Test the share by opening up the "Network" window and browsing the local network. You should be able to see the shared directory.
To Install Printer Sharing
-
7
Find the name of the shared printer and the computer on the network that you want to use. In this case, we'll call it "ServerPrinter" on "Server."
-
8
Log into the machine from which you wish to use the shared printer.
-
9
Open up a command prompt. Go to "Start-->Run." In the "Run" box, type "cmd.exe" (no quotes). In Vista, go to "Start" and enter "cmd.exe" into the "Start Search" box.
-
10
Type in the command "net use lpt1: \\Server\ServerPrinter" (no quotes). "LPT1" is the first available printer port on your machine. If you already have a printer installed locally on this machine, then you would use "LPT2."
-
11
Test the share by sending a print job to the shared printer.
-
1
Tips & Warnings
You can see all of your connected resources across the network by typing "net view" into the command line.
To have these shares reattach themselves when you log back into the network, add the switch "/persistent:yes" to the end of your net statement. For example, to have the drive in Section 1 stay available, type the command "net share SharedDocuments=c:\Documents/persistent:yes" into the prompt (for the second command: "net use lpt1: \\Server\ServerPrinter/persistent:yes").