O'Reilly logo

Windows Server Hacks by Mitch Tulloch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. File and Print

Hacks #48-53

File and print is the traditional bread and butter of networking, and while it’s gradually being overtaken by more advanced document-management solutions, not may companies are planning on retiring their file servers soon. Managing shared folders and printers also makes up a major component of an administrator’s daily routine, and a high proportion of calls to the help desk as well. So it’s worth examining some new ways to do old tasks, such as mapping drives or configuring default printers, as well as some ways to perform tasks that are not easy using standard Windows tools, including mapping the structure of a directory or determining who has a certain file open on the network. That’s what this chapter is about—doing old tasks in new ways and making complex tasks simple.

Map Network Drives

This quick way to map a network drive can replace the traditional approach of using batch files.

Using VBScript, you can easily map drive letters to shared folders on your network. This approach allows you to use VBScript to map and unmap network drives—for example, in logon scripts. It also allows you greater flexibility in customizing scripts to perform actions across a network and doesn’t require the net use command to work.

Basically, the script creates the Network scripting object and then uses the MapNetworkDrive method to assign a drive letter to a network share. I’ve included examples of code for both mapping and unmapping network drives.

The Code ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required