Nepali Posted February 26, 2007 Posted February 26, 2007 (edited) Simply creat a batch file to take the file ownership and to alter it.I hate to take ownership going to system directory, right click, an blah blah blahECHO Taking ownership of the file uxtheme.dlltakeown /f %systemroot%\System32\uxtheme.dllicacls %systemroot%\System32\uxtheme.dll /grant administrators:FEcho Renaming file to uxtheme.oldren %systemroot%\System32\uxtheme.dll uxtheme.oldEcho copying patched uxtheme.dllxcopy /y X:\uxtheme.dll "%systemroot%\System32\"it will be much better if somone could made it better like VBS or EXE just to ask the file name which we wants to take ownership.Registry entry to gain ownershipWindows 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]@="Take 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" Edited March 4, 2007 by Nepali
DigeratiPrime Posted February 26, 2007 Posted February 26, 2007 Thanks for posting this! I was thought of making something like this when I was using Vista, but that only lasted about an hour before I put XP back on...I don't see why this could not be made into a shell extension, aka added to the right-click context menu to make things even easier...[EDIT] untested but here's the idea:Windows Registry Editor Version 5.00;Take Ownership of[HKEY_CLASSES_ROOT\*\Shell\Take Ownership of\command]@="takeown /f %1"@="icacls %1 /grant administrators:F"Might be a variable for %current username% that could replace "administrators" too.
gunsmokingman Posted February 26, 2007 Posted February 26, 2007 Here is a VBS script that uses the code provided by Nepali I have made this a sfx file that extracts to the SendTo FolderSo all you have to do is select the file and then use the SendTo context menu to use the script.Save As OwnTheFile.vbsDim 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)) NextSelf Extracting VBSOwnTheFile.exe
Rudi1 Posted February 26, 2007 Posted February 26, 2007 Thanx for this great and really usefull script for me gunsmokingman,work like a sharm!
Nepali Posted February 27, 2007 Author Posted February 27, 2007 Fantastic.. thats what i was looking for.. a perfect script.Gunsmoking, you are always great on script..
gunsmokingman Posted February 27, 2007 Posted February 27, 2007 Fantastic.. thats what i was looking for.. a perfect script.Gunsmoking, you are always great on script.. I thank you for providing the code for the script
N1K Posted March 2, 2007 Posted March 2, 2007 Not working here, script only makes a copy of the original file with new permissions, but the original file retains it's permissions.
gunsmokingman Posted March 2, 2007 Posted March 2, 2007 Not working here, script only makes a copy of the original file with new permissions, but the original file retains it's permissions.1:\ I copy dfrgui.exe to my desktop2:\ I then used my Sendto OwnTheFile3:\ As you can see it changed the permissions
N1K Posted March 2, 2007 Posted March 2, 2007 Well, I was trying to change the permissions for the "wlsrvc.dll" file in C:\Program Files\Windows SidebarHere's what I did:I've used "own the file" option from a right click selection on that file (C:\Program Files\Windows Sidebar\wlsrvc.dll)The script made a copy of that file with _original extension for the name, and it changed the permissions for that file, not the original one. So now I have original file "wlsrvc.dll" intact with old permissions, and the other file, made by script (wlsrvc_Original.dll) with newly permission setup.I don't need the script to make another file, I'd like to change the permissions on the original file if possible..What am I missing here, help..
gunsmokingman Posted March 2, 2007 Posted March 2, 2007 Try this1:\ Make a folder called shell on %systemdrive%2:\ Copy the file to the new folder then try the ownthefileNoteI do not know how permission work on this I only provided a script to makeit easier to do.Here is the same script but I have removed making a extra file.Save As OneTheFile_V1.vbsDim Act : Set Act = CreateObject("Wscript.Shell")Dim File1 For Each File1 in Wscript.Arguments Act.Run("takeown /f " & File1),0,True Act.Run("icacls " & File1 & " /grant administrators:F"),1,True NextJust open the original script with notepad and select alland paste the above code in it to not make a extra copy.
Nepali Posted March 3, 2007 Author Posted March 3, 2007 (edited) heres the slightly changed Script ...ECHO Taking ownership of the file uxtheme.dlltakeown /A /f %systemroot%\System32\uxtheme.dllicacls %systemroot%\System32\uxtheme.dll /grant administrators:FEcho Renaming file to uxtheme.oldren %systemroot%\System32\uxtheme.dll uxtheme.oldEcho copying patched uxtheme.dllxcopy /y X:\uxtheme.dll "%systemroot%\System32\"but this didn't workDim Act : Set Act = CreateObject("Wscript.Shell")Dim File1 For Each File1 in Wscript.Arguments Act.Run("takeown /A /f " & File1),1,True Act.Run("icacls " & File1 & " /grant administrators:F"),1,True Nextthis screen popuped once while executing VBS script, does this have any meaning. I only changed the text with BOLD Edited March 3, 2007 by Nepali
gunsmokingman Posted March 3, 2007 Posted March 3, 2007 I ran it and got no errors.Are you drag and dropping it on the file, or are you using the sendto folder.I just drag and drop the file on my desktop to test.
Nepali Posted March 3, 2007 Author Posted March 3, 2007 actually what i have noticed is The 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.exeBut the batch script works for both directory, what could be the problemif i copy the same iexplore.exe to the desktop, it loss the ownership by default, it doesn't need to take the ownership of the file.So ownership should be taken from the default folder where the actual file reside.
gunsmokingman Posted March 3, 2007 Posted March 3, 2007 I tried this script on wmplayer.exe and it change the permission for the admin.I just drag and drop it on the this script Save as OwnTheFile_V2Dim 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 Next
Nepali Posted March 3, 2007 Author Posted March 3, 2007 (edited) Working perfect...please add the script to rename the file for backup purpose well.. as for previous one..B) Edited March 3, 2007 by Nepali
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now