Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


January 2002

A Pair of Resource Kit Gems


RSS
Subscribe to Windows IT Pro | See More Printing Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Add a network printer to a workstation and determine what process is using a file

In this column, I have two handy resource kit utilities to share. The first, Con2prt, lets you add a network printer to a workstation, make a network printer the default printer, or clear all printers from the workstation. To make a network printer named \\server1\hplaser the default printer for the workstation you're sitting at, type

con2prt /cd \\server1\hplaser

To add the printer without making it the default, drop the d from the command string. To clear all printers from the workstation, use the /f switch instead of /cd or /c.

You can use a Telnet session to run Con2prt on a remote workstation. The tool also works in batch files. For example, a batch file that contains the statements

con2prt /f
con2prt /cd \\server1\printer1
con2prt /c \\server1\printer2

will delete all existing printer connections, add Printer1 as the default printer, then add Printer2.

You'll find Con2prt in the Microsoft Windows 2000 Resource Kit and in the Zero Administration Kit (ZAK) for Windows (available at http://www.microsoft.com/windows/zak/getzak.htm). To use the tool, you need only the con2prt.exe file; no complex installation is required.

The second tool, OH (for "open handles"), helps when you try to delete a directory only to have the OS tell you that a file in the directory is "in use by another process." In the past, I've used Sysinternals' great Filemon utility (available at http://www.sysinternals.com) or an old copy of Windows File Manager from Windows NT 3.51 to determine which process was using the file. But I recently discovered a resource kit tool called OH that does the job. (To my embarrassment, OH apparently has been around for quite a while.) OH has many options. I'll give you the short version for finding out what program is preventing you from deleting a file.

Before OH will work, you need to run it once. The first invocation modifies Win2K's kernel a bit, adding 8 bytes of information to each running process. Theoretically, that overhead will slow the system, but I've done before-and-after comparisons on several systems and have found no detectable difference in performance or memory utilization. (The resource kit Help file says that you can undo the kernel change later with a tool called gflags.exe, but I haven't tried it.) The worst part of using OH seems to be that a reboot is required for the kernel behavior modification.

After rebooting, you can tell OH to identify the process that's using any given file by typing the command

oh -t file <filename>

The -t switch tells OH that you want information about a particular type of object—a file, in this case. Filename is the name of the file you're interested in.

If you're unsure of the file's name, OH can still help. You can't use the common wildcards (i.e., ? and *) with OH, but you can type the first few characters of the file's name to have OH list all the files in use whose names begin with those characters. Thus, if you know that the file's name is process1.dat or process2.dat, you can just type

oh -t file process

to see whether a file called process1 or process2 is in use.

If you know only the file's extension, type

oh -t file

to dump the name of every file in use. Then, pipe the output through the Find filter to narrow the list to a particular extension. For example, to find all files in use that have the extension .pl, type

oh -t file | find ".pl"

I'll have more gems in my next column.

End of Article



Reader Comments
I have been trying to get the con2prt executable to work on NT4.0 & W2K Pro machines in our SBS4.5 environment. The reason for this to ease the migration to W2K3 Server STD. The server name for the printserver will change from server1 to server01. The command will not cause a printer connection unless the userid has Domain Admin privileges. I also have tried another approach utilizing "rundll32 printui.dll,PrintUIEntry ..." as described in MS article id 189105 & at www.robvanderwoude.com web site. This did function properly unless the userid has Domain Admin privileges.

From what I have read, it does seem necessary to have any administrator privileges to execute these techniques.

One final note - I had been using a policy file in the SBS4.5 environment. This may have an impact, I do not know.


rlmink June 18, 2005 (Article Rating: )


You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
CES 2009: Ballmer Announces Windows 7, Windows Live, Live Search Milestones

During his first-ever Consumer Electronics Show (CES) 2009 keynote address last night in Las Vegas, Microsoft CEO Steve Ballmer announced the pending public availability of a feature-complete Windows 7, the final version of Windows Live Essentials, and ...

10 Reasons Not to Deploy Windows Vista

The decision to upgrade to Vista has to make business sense, but many companies find the costs in training and application compatibility problems outweigh any benefits Vista brings. ...

10 Reasons to Deploy Windows Vista

The decision to upgrade your XP systems to Vista is simple when you consider features such as easier backup, a great desktop search, and vastly improved security options. ...


Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Related Events Virtualization Forum: Optimizing Storage, Networks, Desktops, and Security

Cloud Computing Forum: Integrating Software, Server and Storage as a Service into Your Enterprise IT Delivery Model

Virtualization Forum: Optimizing Storage, Networks, Desktops, and Security

Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2009 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing