Windows – Command Prompt change file icon

command linewindowswindows 10

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.

Best Answer

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