Command Prompt change file icon

8,074

You can to do this very easily with the right tools in the windows console, or write a BAT program to do this for you.

First, you need to find the association value.

ECHO WHAT ASSOC FILE ICON ARE WE EDITING? 
SET /P VAR=  

Next, you need provide the icon file path

ECHO WHERE IS THE ICON LOCATED? 
SET /P VAR2=

Finally, you can write a script to edit this.

That would look like:

echo Windows Registry Editor Version 5.00 >>tmp.reg
echo [HKEY_CLASSES_ROOT\%var%\DefaultIcon\] >>tmp.reg
echo "(Default)"="%var2%" >>tmp.reg

than you can run the file with

start tmp.reg
Share:
8,074

Related videos on Youtube

Samuel
Author by

Samuel

Updated on September 18, 2022

Comments

  • Samuel
    Samuel over 1 year

    It is possible to change file associations using the command prompt

    assoc .c=Cfile
    ftype Cfile="C:\emacs\bin\emacsclient" -n "%1"
    

    Is there a way to change the icon of a file this way also. Or is the best way to do this by editing the registry.

    I want to make a script or C program to do this so I don't want a icon association program.

  • Franky
    Franky over 6 years
    Would you please take a look at this please? I'm going to set an icon on a file type using a script file.