Jump to content
Sign in to follow this  


Recommended Posts

Hey there :)

This is one of my first UDFs that I publish and I wanted to share it with you :)

It's just a simple Function to change some things on a Folder, for example the Icon and the BG Image :P

$pFolder is the Path to the Folder

$pIcon the Path to the Icon

$pIconIndex is the Index if the Icon is referring a dll

$sInfoTip will display a ToolTip when the Mouse is over the Folder

$pBG is the Path to the pattern Image

Func _SetFolderIcon($pFolder,$pIcon,$iIconIndex=0,$sInfoTip="",$pBG="")
    If StringInStr(FileGetAttrib($pFolder & "\desktop.ini"),"R") Then FileSetAttrib($pFolder & "\desktop.ini","-R")
    IniWrite($pFolder & "\Desktop.ini",".ShellClassInfo","IconFile",$pIcon)
    IniWrite($pFolder & "\Desktop.ini",".ShellClassInfo","IconIndex",$iIconIndex)
    If NOT $sInfoTip = "" Then IniWrite($pFolder & "\Desktop.ini",".ShellClassInfo","InfoTip",$sInfoTip)
    If NOT $pBG = "" Then IniWrite($pFolder & "\Desktop.ini","{BE098140-A513-11D0-A3A4-00c04FD706EC}","IconArea_Image",$pBG)
    FileSetAttrib($pFolder & "\Desktop.ini","+RSH")
    Return 1

Hope that somebody might find this usefull :P

It can be also improved to change some textColors I think, but that should be okay

Ah and don't forget to refresh either the Folder or if you changed the BG of it to go out the folder and in again :(


Share this post

Link to post
Share on other sites

I like this, it should prove useful.

I have a suggestion though, it wouldn't be that hard to detect if the window that your changing is open so you could automatically refresh it if it is open (or if it's a folder in quick launch then refresh that). That's just my opinion...

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post

Link to post
Share on other sites

A while ago i needed such function, and i wrote it like this :):

Func _DirSetIcon($Dir_Path, $IconFile, $IconIndex=0, $TipText="")
    If Not StringInStr(FileGetAttrib($Dir_Path), "D") Then Return SetError(1, 0, -1)
    $Dir_Path = StringRegExpReplace($Dir_Path, '\\+\z', '')
    If StringRight($Dir_Path , 1) = ':' Then
        Local $IconStr = '"' & $IconFile & '", ' & $IconIndex
        If $IconIndex = 0 Then $IconStr = $IconFile
        If $IconFile = -1 Then $IconStr = ''
        IniWrite($Dir_Path & '\Autorun.inf', 'Autorun', 'icon', $IconStr)
        DriveSetLabel($Dir_Path, DriveGetLabel($Dir_Path))
        Return 1
    Local $DirSetFile = $Dir_Path & "\Desktop.ini"
    FileSetAttrib($DirSetFile, "-R")
    IniWrite($DirSetFile, ".ShellClassInfo", "IconFile", $IconFile)
    IniWrite($DirSetFile, ".ShellClassInfo", "IconIndex", $IconIndex)
    IniWrite($DirSetFile, ".ShellClassInfo", "InfoTip", $TipText)
    FileSetAttrib($DirSetFile, "+R")
    If Not FileSetAttrib($Dir_Path, "S") Then Return SetError(2, 0, 0)
    If Not FileSetAttrib($DirSetFile, "+HS") Then Return SetError(3, 0, 0)
    $ExplorerWinArr = WinList("[CLASS:CabinetWClass]")
    For $i = 1 To $ExplorerWinArr[0][0]
        If ControlGetText($ExplorerWinArr[$i][1], "", "Edit1") = StringLeft($Dir_Path, StringInStr($Dir_Path, "\", 0, -1)) Then
            WinWaitActive($ExplorerWinArr[$i][1], "", 5)
    Return 1

As you can see, it works also on Drives.

Edited by MsCreatoR



Using OS: Win 7 Professional, Using AutoIt Ver(s): /

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...


AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *





AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...