Is there a way to change the Windows folder icon using a Perl script?
I intend to change the general icon of "Xxx_documents" folder to some other icon to run this script in this way that it takes care of the entire drive.
There are several folders in this drive. I have to search for each folder called "document" (for example "xxx_documents" or simply "documents") and "% SystemRoot% \ system32 \ SHELL32.dll" " From the library your icon must be changed with one.
Is this possible in Perl? Thanks to everyone who help me with this.
You can do it with Perl Windows in each folder in a hidden system Dekstop. Ini controls the directory icon using the file. The content looks like this:
[.shellClassInfo] IconFile =% SystemRoot% \ system32 \ SHELL32.dll IconIndex = 41 on Windows XP (and I take it on other systems), the icon 41 is a tree. Windows has to set this file to be set as a system file explicitly, that means we need to create it in Win32API :: File Dig:
#! Use / usr / bin / perl strict; Use warnings; Use Win32API :: File qw (createFile WriteFile fileLastError CloseHandle); My $ file = createFile ('Desktop.ini', {access = & gt; 'w', # Write Access Properties = & gt; 'hs', # Create Hidden System File = & gt; 'TC', #Tranket / Make}} or die "Can not make Desktop.ini" - fileLastError (); WriteFile ($ file, "[.sellClassInfo] \ r \ n". "IconFile =% SystemRoot% \\ system32 \\ SHELL32.dll \ r \ n". "IconIndex = 41 \ r \ n", 0, [] , []) Or die "can not write the desktop .i" - "fileLastError (); CloseHandle ($ file) or die" Can not close Desktop.ini "-" fileLastError (); If you run the above code, then it should set the icon on a tree for the current directory.
Now that we have a way to change the icons, we can now walk through the entire drive and change each folder that matches our pattern. We can do this easily with file :: find , or one of its options (e.g., file :: find :: rule , or File :: next ):
#! Use / usr / bin / perl strict; Use warnings; Use the file: search qw (search); Use Win32API :: File qw (createFile WriteFile fileLastError CloseHandle); My $ TopDir = $ ARGV [0] or Dead "Usage: $ 0 Path \ n"; Find (& amp; change icon, $ topdir); Sub-change icon (if not return / document $ / i; # Skip non-document folders, if not -d; # Skip non-directories My $ file = createFile ("$ _ \\ Desktop.ini", {access = & gt; 'w', # Write Access Properties = & gt; 'hs', # Create Hidden System File = & Gt; 'TC', #Tanket / Creating}) or die "Desktop.fileLastError (); WriteFile ($ file," [.sellClassInfo] \ r \ n "." IconFile =% SystemRoot% \\ system32 \ SHELL32 .dll \ r \ n "." IconIndex = 41 \ r \ n ", 0, [], []) or die" Desktop can not write .i "-" fileLastError (); CloseHandle ($ file) or die can not close "Desktop.ini" - "fileLastError ();} Unfortunately, I just learned that if only icon is currently, or once, was an icon ... there is clearly one attribute that is being set on the directory which will see the Desktop.ini file on Windows But I do not know what it is for his life, for example, the above solution is incomplete; Is to find the characteristics of the complaints and s and must be put right where we are adding icon.
Paul
Comments
Post a Comment