NIM Posted February 26, 2007 Posted February 26, 2007 You have probably run into the situation, where you had to take ownership of the file or folder in Vista, so you can mess with it..To fasten this process a bit, you can use this script, which will add an option in context menu for the file.Right click on the file --> Send To --> OwnThefile.Here's the code for the script:Dim Act : Set Act = CreateObject("Wscript.Shell")Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")Dim File, File1, File2 For Each File1 in Wscript.Arguments Act.Run("takeown /f " & File1),0,True Act.Run("icacls " & File1 & " /grant administrators:F"),1,True File2 = Split(File1,".") Set File = Fso.GetFile(File1) File.Copy(File2(0) & "_Original." & File2(1)) NextSave it as .vbs file and run it.Or you can use attached file which actually is self extracting .vbs script.OwnTheFile.rar Quote
MrNxDmX Posted February 28, 2007 Posted February 28, 2007 Wow, havent tried, bu a great time saver. That process killing my nerves.Thanks for share. Quote
NIM Posted March 2, 2007 Author Posted March 2, 2007 don't workCan you provide more information. Did you get a right click option to take file ownership or not at all. Or this script won't take ownership of the file.. Quote
NIM Posted March 3, 2007 Author Posted March 3, 2007 I've noticed that VBS script works on the files directly in system32 directory Eg: sysdm.cpl, syssteup.dllbut it didn't work for program files directory or files Eg: iexplore.exe or Sidebar.exeHere's the code for a new script that is working for sure (save it with .vbs extension).Just drag and drop the original file on the script and it'll modify permissions for the original file and make another copy of the same file in the source directory (backup)..Dim Act : Set Act = CreateObject("Wscript.Shell")Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")Dim File1, File2For Each File1 in Wscript.Arguments Act.Run("takeown /A /f " & Chr(34) & File1 & chr(34)),1,True Act.Run("icacls " & Chr(34) & File1 & chr(34) & " /grant administrators:F"),1,TrueFile2 = Split(File1,".")Set File = Fso.GetFile(File1)File.Copy(File2(0) & "_Original." & File2(1))Nextor download this file:takeown.vbs Quote
NIM Posted March 3, 2007 Author Posted March 3, 2007 Here are two sfx files.One will take ownership of the original file and made a copy of that file.Dim Act : Set Act = CreateObject("Wscript.Shell")Dim File1For Each File1 in Wscript.Arguments Act.Run("takeown /A /f " & Chr(34) & File1 & chr(34)),1,True Act.Run("icacls " & Chr(34) & File1 & chr(34) & " /grant administrators:F"),1,True NextOwnTheFile_V2.exeSecond will only take ownership of the original file.Dim Act : Set Act = CreateObject("Wscript.Shell")Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")Dim File, File1, File2For Each File1 in Wscript.Arguments Act.Run("takeown /A /f " & Chr(34) & File1 & chr(34)),0,True Act.Run("icacls " & Chr(34) & File1 & chr(34) & " /grant administrators:F"),0,TrueFile2 = Split(File1,".")Set File = Fso.GetFile(File1)File.Copy(File2(0) & "_Original." & File2(1))NextOwnTheFile_V3.exeYou can use it by clicking right clicking on the desired file and choosing the option "send to" --> "own the file". Quote
NIM Posted March 6, 2007 Author Posted March 6, 2007 Here's the .reg file that will give you the SHIFT + Right Click = Gain Ownership context menu Windows Registry Editor Version 5.00[HKEY_CLASSES_ROOT\*\shell\runas]@="Gain Ownership""Extended"="""NoWorkingDirectory"=""[HKEY_CLASSES_ROOT\*\shell\runas\command]@="cmd.exe /c takeown /A /f \"%1\" && icacls \"%1\" /grant administrators:F""IsolatedCommand"="cmd.exe /c takeown /A /f \"%1\" && icacls \"%1\" /grant administrators:F"[HKEY_CLASSES_ROOT\Directory\shell\runas]@="Gain Ownership""Extended"="""NoWorkingDirectory"=""[HKEY_CLASSES_ROOT\Directory\shell\runas\command]@="cmd.exe /c takeown /A /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t""IsolatedCommand"="cmd.exe /c takeown /A /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"ownership.reg Quote
amaedict Posted February 14, 2008 Posted February 14, 2008 (edited) What if i want to take ownership of a specific file. Say for example i want to take ownership of a file inside the windows system 32 folder. but i dont want to browse all the way there and then right click. Is there a way i can just have a vbscript that i can run from anywhere that will just automaticly take ownership of that specific file and rename it to .old ?This would be really handy for replacing the mui file for example when you wanna remove the watermark from vista sp1. Is it possible tho ? Edited February 14, 2008 by amaedict Quote
NIM Posted May 2, 2008 Author Posted May 2, 2008 That would be much harder to achieve. I could do it so you enter the name of the file in the prompt box but I would have to specify the target directory in the script.What if i want to take ownership of a specific file. Say for example i want to take ownership of a file inside the windows system 32 folder. but i dont want to browse all the way there and then right click. Is there a way i can just have a vbscript that i can run from anywhere that will just automaticly take ownership of that specific file and rename it to .old ?This would be really handy for replacing the mui file for example when you wanna remove the watermark from vista sp1. Is it possible tho ? Quote
Primavera Posted April 18, 2009 Posted April 18, 2009 ownership.regWorking perfect on Vista Ultimate...Thanks very much. Quote
AMIRZ Posted April 18, 2009 Posted April 18, 2009 Lol nice bump! And really pretty nice tweak thanks! :thumbsup_anim: Quote
babu Posted June 13, 2009 Posted June 13, 2009 When i want to name a folder it cannot be named.Can this file help. Quote
NIM Posted June 13, 2009 Author Posted June 13, 2009 this script can't, it would have to be modified and question box inserted.. Quote
AMIRZ Posted June 13, 2009 Posted June 13, 2009 Also you can't name/rename a folder usually because one or more processes may "use" it when running in memory (i.e when you open a file that is in the folder using default app etc). Just restart Windows Explorer or close/stop the current app/process by using Task Manager etc Quote
babu Posted June 14, 2009 Posted June 14, 2009 Even after creating a new folder it cannot be named.Please clarify my doubt. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.