supraspecies Posted May 10, 2013 Share Posted May 10, 2013 Searched the forum, but failed to find a solid answer how to do that. Specifically, I need to take ownership of aero.msstyles file to install a custom Windows 7 theme. Link to comment Share on other sites More sharing options...
Neutro Posted May 10, 2013 Share Posted May 10, 2013 (edited) Hey, You could give UDF a try ; #FUNCTION# ==================================================================================================================== ; Name...........: _SetObjectOwner ; Description ...: Sets the owner of an object. ; Syntax.........: _SetObjectOwner($oName, $_SE_OBJECT_TYPE, $AccountName) ; Parameters ....: $oName - The name or handle to the object. This can be a path to a file or folder, a registry key, ; + a service name, a process handle, etc. See the comments on the _SE_OBJECT_TYPE enum for more info. ; $_SE_OBJECT_TYPE (Optional) - The type of the object to set permissions. This must be one of the values of the ; +_SE_OBJECT_TYPE enum. The default is $SE_FILE_OBJECT (a file or folder). ; $AccountName (Optional) - The account name or SID string to set. the default is the administrators group. ; +Can be any user name or SID string, see GetSidStruct() for more info. ; Return values .: Success - 1 ; Failure - 0 and sets @error ; Author ........: FredAI ; Modified.......: ; Remarks .......: ; Related .......: _GetSidStruct ; Link ..........: ; Example .......: _SetObjectOwner('C:\Example.txt') Edited May 10, 2013 by Neutro supraspecies 1 Identify active network connections and change DNS server - Easily export Windows network settings Clean temporary files from Windows users profiles directories - List Active Directory Groups members Export content of an Outlook mailbox to a PST file - File patch manager - IRC chat connect example Thanks again for your help Water! Link to comment Share on other sites More sharing options...
supraspecies Posted May 10, 2013 Author Share Posted May 10, 2013 (edited) @Neutro, thanks a lot! While I was looking, I figured out an easy way: $STYLEFILE=(@WindowsDir & '\Resources\Themes\Aero\aero.msstyles') Run(@ComSpec & " /C " & 'TAKEOWN /F ' & $STYLEFILE, '', @SW_HIDE) Run(@ComSpec & " /C " & 'icacls ' & $STYLEFILE & ' /grant administrators:F /t', '', @SW_HIDE) But I noticed nobody is using it. Is something wrong with it? Doesn't work under some circumstances? Edited May 10, 2013 by supraspecies Link to comment Share on other sites More sharing options...
Neutro Posted May 10, 2013 Share Posted May 10, 2013 Seems good to me as well Maybe using the Set ACL UDF will be faster since you do not need to call an external software (takeown & icalcs) to do this, but if it's just for a few files then it doesn't really matter i guess! Identify active network connections and change DNS server - Easily export Windows network settings Clean temporary files from Windows users profiles directories - List Active Directory Groups members Export content of an Outlook mailbox to a PST file - File patch manager - IRC chat connect example Thanks again for your help Water! Link to comment Share on other sites More sharing options...
supraspecies Posted May 10, 2013 Author Share Posted May 10, 2013 One file. But I'll still try out UDF you posted because I myself don't want to call external software unless necessary. Thank you, and topic can be considered closed. Link to comment Share on other sites More sharing options...
careca Posted May 11, 2013 Share Posted May 11, 2013 (edited) Ownership.reg:RMB over the file/s to own.Windows Registry Editor Version 5.00;=============================================================================;Take ownership Users[HKEY_CLASSES_ROOT*shellown]@="Users Ownership""NoWorkingDirectory"="""Icon"="C:ICOown.ico"[HKEY_CLASSES_ROOT*shellowncommand]@="cmd.exe /c takeown /f "%1" /r /d y && icacls "%1" /grant Users:F /t""IsolatedCommand"="cmd.exe /c takeown /f "%1" /r /d y && icacls "%1" /grant Users:F /t"[HKEY_CLASSES_ROOTDirectoryshellown]@="Users Ownership""NoWorkingDirectory"="""Icon"="C:ICOown.ico"[HKEY_CLASSES_ROOTDirectoryshellowncommand]@="cmd.exe /c takeown /f "%1" /r /d y && icacls "%1" /grant Users:F /t""IsolatedCommand"="cmd.exe /c takeown /f "%1" /r /d y && icacls "%1" /grant Users:F /t"[HKEY_CLASSES_ROOTDriveshellown]@="Users Ownership""NoWorkingDirectory"="""Icon"="C:ICOown.ico"[HKEY_CLASSES_ROOTDriveshellowncommand]@="cmd.exe /c takeown /f "%1" /r /d y && icacls "%1" /grant Users:F /t""IsolatedCommand"="cmd.exe /c takeown /f "%1" /r /d y && icacls "%1" /grant Users:F /t";============================================================================= Edited May 11, 2013 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
supraspecies Posted May 11, 2013 Author Share Posted May 11, 2013 @ careca Already have that on my system, has nothing to do with AutoIT. I wanted my script to take ownership on its own. And even though I could make it click on mouse context menu option, it wouldn't be proper because it would work only for those who actually have that option in context menu. Link to comment Share on other sites More sharing options...
UEZ Posted May 11, 2013 Share Posted May 11, 2013 Maybe this helps, too. Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
supraspecies Posted May 11, 2013 Author Share Posted May 11, 2013 (edited) I'm testing that UDF on a random system file, and no go. #include <Permissions.au3> #RequireAdmin _GrantAllAccess(@WindowsDir & '\System32\advapi32.dll') It works for non-system files (user-created), but on system files it does nothing for me. It reports success, but nothing changes. And yes, I'm running it as admin. I even have UAC turned off. Any ideas? Actually - I'm wrong. Depends on files. Seems to work for Windows theme files, but DLLs in System32 - nope. I don't need my script to access them at the moment, but someday i might... So I'm asking. P.S. If you're wondering what is all this for - customizing Windows 7 installation. Unattended. @ UEZ Appreciate it, trying now. Edited May 11, 2013 by supraspecies Link to comment Share on other sites More sharing options...
careca Posted May 11, 2013 Share Posted May 11, 2013 @ careca Already have that on my system, has nothing to do with AutoIT. I wanted my script to take ownership on its own. And even though I could make it click on mouse context menu option, it wouldn't be proper because it would work only for those who actually have that option in context menu. Yeah, but you could use the same commands in autoit. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
spudw2k Posted May 13, 2013 Share Posted May 13, 2013 Just for troubleshooting, if you take a regular file and add the system attribute does it behave the same way? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
supraspecies Posted August 18, 2013 Author Share Posted August 18, 2013 (edited) Actually - I'm wrong. Depends on files. Seems to work for Windows theme files, but DLLs in System32 - nope. I don't need my script to access them at the moment, but someday i might... So I'm asking. That day has come. I need to replace shellstyle.dll in System32 on first Windows 7 launch (post-install). Permission script above and takeown do not work with files located in System32. How can my script gain permissions needed to replace files in System32 folder? In case youre wondering - not using it for any malicious purpose. I have customized my Windows and made an unattended install for it. This file contains modded Classic Theme for Windows, and I need my Windows to install with this theme by default. Edited August 18, 2013 by supraspecies Link to comment Share on other sites More sharing options...
careca Posted August 19, 2013 Share Posted August 19, 2013 safe mode? Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
MHz Posted August 19, 2013 Share Posted August 19, 2013 In Windows XP, it was known as Windows File Protection. Later it become Windows Resource Protection. This is perhaps the problem. In XP you could replace the file in the dllcache folder and then the file in the system32 folder. In Vista+, I am not sure how it is done at this moment. Link to comment Share on other sites More sharing options...
careca Posted August 19, 2013 Share Posted August 19, 2013 Maybe http://www.xptsp.com/fixit/replacer.php Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
supraspecies Posted September 1, 2013 Author Share Posted September 1, 2013 (edited) Solved it (with a help from a friend). If anyone needs to know how to replace files in System32 (including x64 edition of Windows), here is the way: #requireadmin DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1) $STYLEFILE=(@WindowsDir & '\System32\shellstyle.dll') Run(@ComSpec & " /c " & 'TAKEOWN /F ' & $STYLEFILE, '', @SW_HIDE) Run(@ComSpec & " /c " & 'cacls.exe ' & $STYLEFILE & ' /E /P BUILTIN\Administrators:F', '', @SW_HIDE) DllCall("kernel32.dll", "int", "Wow64EnableWow64FsRedirection", "int", 1) This will grant you all permissions to do whatever you wish. Edited September 1, 2013 by supraspecies Synapsee 1 Link to comment Share on other sites More sharing options...
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