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 


March 2007

The Lowdown on Takeown

Check out this quick, simple-syntax tool for taking ownership of files
RSS
Subscribe to Windows IT Pro | See More Administration Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Ever since Windows Vista appeared, readers have repeatedly sent me the same question: "Why can't I modify the HOSTS file?" Many people modify the

HOSTS file—located in \windows\system32\drivers\etc—to protect the system from sites that promote the spread of malware. However, Vista blocks this kind of modification. By default, Vista administrators don't have permission to delete most files in the \windows directory—nor do they own those files. Therefore, to modify HOSTS, you first need to take ownership of the file. You've been able to take ownership of a file from the GUI ever since Windows NT 3.1, but that built-in capability isn't terribly useful for remote administration. Fortunately, Vista and Windows Server 2003 include a new command-line tool called Takeown that lets you take ownership of files or folders.

How It Works
Takeown's basic syntax looks like

takeown /f <file or folder name> 

You'll probably need to run Takeown with your full administrative powers, and Vista's User Account Control might get in the way of that. Therefore, before you try to run Takeown, go to Start, All Programs, Accessories, Command Prompt—as you've probably done many times. But this time, in Vista, right-click the Command Prompt icon and choose Run as administrator. After you verify the action by clicking Confirm, you'll have what Vista refers to as an elevated command prompt.

You can now take ownership of your system's HOSTS file:

takeown /f C:\windows\system32\drivers\etc\hosts 

(This command assumes that you have Vista on the C drive, of course. If Vista actually resides somewhere else, just change the drive letter.) Vista will respond with something like

SUCCESS: The file (or folder): "C:\windows\ 
  system32\drivers\etc\hosts" now owned by user 
  <youraccountname>. 

At this point, you can assign yourself write permissions to the HOSTS file and make changes.

Takeown has more options than just /f, of course. To take ownership of an entire tree of folders and files, you can add the /r option. Thus, if you wanted to take ownership of a folder named C:\documents, as well as any files and folders inside C:\documents, you'd type

takeown /f C:\documents /r

Tackling an Annoyance
If you've ever tried to take ownership of a tree of folders, you might have run into something of an annoyance—namely, Windows' tendency to ask if you really, truly want to take ownership. Suppose, for example, that you not only don't own C:\documents but you also don't have permission to look in C:\documents. In that case, taking ownership of C:\ documents wouldn't equip you to take control of any subfolders in C:\documents for the simple reason that although you would now own C:\documents, you would still lack the NTFS permissions necessary to list its subfolders.

Feasibly, you could take ownership of each directory, one at a time, then add a list folders permission to that folder, which would let you see the subfolders in that folder, which in turn would let you take ownership of the subfolders. Thankfully, such manual labor isn't necessary: Whenever you use the /r option with Takeown, the command pauses at each folder and asks whether you'd like Takeown to add the list folders permission to that folder's NTFS permissions. That's a nice touch, but it means that taking control of a folder containing dozens of folders could get a bit tedious.

The good news is that you can configure Takeown so that it doesn't ask you if you want to add the list folders permission and instead just assumes that you'll answer yes or no. To do that, you use the /d option, followed by a y or an n. So, to take ownership of C:\documents and all its subfolders, while granting yourself the list folders permission, you'd type

takeown /f C:\documents /r /d y 

Note, however, that in the process of giving you permission to list folders, Takeown /r first removes any other explicit permissions on that folder! Inherited permissions seem unaffected in my tests, however.

Own It!
To my knowledge, Windows has previously offered only one command-line tool to take ownership: the resource kit's Subinacl tool. Subinacl is a powerful tool, but its syntax can require some study. Takeown offers a command-line alternative with simple syntax.

End of Article



Reader Comments
It appears that Takedown doesn't actually exist. I searched a Vista, W2K3, and W2K8 computer and none of them had it.

masonth@comcast.net September 30, 2007 (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
Friday at PASS Europe 2006

Kevin talks about the closing day of the event and shares a funny Microsoft film. ...

WinInfo Short Takes: Week of September 8, 2008

An often irreverent look at some of the week's other news, including the long-awaited back to school season, Microsoft's first Seinfeld/Gates ad, some EU insights, another Netbook improvement, Opera silliness, and much, much more ...

IE 8.0 and Chrome Could Enable Next-Gen Web Apps—Unless Your ISP's Bandwidth Cap Gets in the Way

Both browsers are being positioned as the core system application that will enable the next generation of web apps--however, ISP usage caps could throw a major monkey wrench at web-based application delivery. ...


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

Are You Satisfied?

A Preliminary Look at Deployment Plans for Microsoft Windows Vista

Related Events 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.

Job Openings in IT


ADS BY GOOGLE SPONSORED LINKS FEATURED LINKS

IT Connections
Dive into the new Microsoft platforms and products you implement and support with the experts from Microsoft, TechNet Magazine, Windows ITPro and industry gurus. There are 70+ sessions and interactive panels with networking opportunities.

Attention User Group Leaders...
Announcing the eNews Generator—a FREE HTML e-newsletter builder for user group leaders. Build your HTML and text e-newsletters in minutes and add Windows IT Pro & SQL Server Mag articles alongside your own message!.

Master SharePoint with 3 eLearning Seminars
Learn how to build a better SharePoint infrastructure and enable powerful collaboration with MVPs Dan Holme and Michael Noel. Register today!

Get SQL Server 2008 at WinConnections
Don’t miss Microsoft Exchange and Windows Connections conferences, the premier events for Microsoft IT Professionals in Las Vegas, November 10-13. Every attendee will receive a copy of SQL Server 2008 Standard Edition with one CAL.



Interested in Email Encryption?
Read about the advantages of identity-based encryption in this free report.

Order Your SQL Fundamentals CD Today!
Learn how to use SQL Server, understand Office integration techniques and dive into the essentials of SQL Express and Visual Basic with this free SQL Fundamentals CD.

Virtualization Congress Oct. 14-16 in London
Don't miss Virtualization Congress, the premiere EMEA conference dedicated to hardware, OS and application virtualization. Oct. 14-16.
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 Technical Resources Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing