Sign In

ComfyUI Portable Taskbar Icon (Windows)

7
ComfyUI Portable Taskbar Icon (Windows)

Are you frustrated with your ComfyUI install because you can't pin to the taskbar?
This article solves just that.

Background

This is my obligatory technical explanation. If you don't care about it and just want to follow the step by step guide, skip to the next section.

Why couldn't you just drag the .bat file to the taskbar?

You probably even tried with a shortcut to the .bat and it didn't work.

We can only pin executable binary files to the Windows Taskbar, that means programs, compiled executables.
The .bat file is a script file, a text executable in a way, not a program.

That script is actually calling the python binary executable of the virtual environment for ComfyUI portable.

We need to trick Windows to let it pin our shortcut.

Step by Step guide

Step 1: Pretty icon

Vanity first. We want a pretty icon on the taskbar.

  • There is no real official logo, so just grab an image that represent ComfyUI for you.

  • I took the avatar of the repository.

  • Resize to a square. Crop to a circle. Resize to 256x256. Convert to a .icoicon file.

I use the command line utility called imagemagick to do all that with one command. You can use Photoshop or GIMP or what ever you like.

I provide my icon .ico file in the attached zip file.

Step two: Edit your bat script

After we pin our shortcut to the taskbar, our .bat will be called in a different manner by Windows. We need to edit the file to make sure it launches properly.

If we do not, ComfyUI will be called inside C:\Windows\System32 and break. It's also dangerous for your computer.

I run on a Nvidia GPU, so I edit the run_nvidia_gpu.bat file. You might need to edit the run_cpu.bat.

Edits

Here is the list of what to change, then I will give you 3 examples:

  1. Make a backup copy of the .bat file.

  2. If ComfyUI is installed on C:, skip to 2. If the drive is not C: your first line will set the drive. I set mine to G:.

  3. On a new line change directory with the cd command, followed by the path to your ComfyUI install. For me it is cd "G:\ai-image\ComfyUI_windows_portable"

  4. On the same line we use the & operator to chain call ComfyUI .\python_embeded\python.exe -s ComfyUI\main.py. You will have to add --windows-standalone-build for ComfyUI portable.

  5. Finally, we can add some optional configuration changes to ComfyUI:

    • I change the input directory location

    • I change the output directory location

    • I ask ComfyUI to behave as a local server so that I can open the GUI on my phone in my home network. For that I add the host (listen) and the port.

Examples

Required changes — if you installed on the same drive (C:)

cd "C:\ai-image\ComfyUI_windows_portable" & .\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build
pause

Required changes — if you installed on another drive (example G:)

G:
cd "G:\ai-image\ComfyUI_windows_portable" & .\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build
pause

My .bat file looks like this:

G:
cd "G:\ai-image\ComfyUI_windows_portable" & .\python_embeded\python.exe -s ComfyUI\main.py ^
--windows-standalone-build ^
--listen 192.168.2.184 ^
--port 8188 ^
--output-directory G:\ai-image\out ^
--input-directory G:\ai-image\inputs ^
--preview-method auto
pause

Step 3: Make a shortcut

  1. Right click the run_nvidia_gpu.bat file (or run_cpu.bat) and click Create a shortcut.

  2. Right click the shortcut and open its properties.

  3. Change the icon, click Change Icon... then Browse... to the location of the .ico file.

Step 4: Trick windows

Now to trick Windows into letting us pin a shortcut to a .bat on the Taskbar.

  • In the shorcut properties, add explorer.exe in the Target field, before the path to the bat file.

  • Save and close with OK.

  • Right click on the Shortcut. You should have a new option pin to Taskbar, click it.

  • Do not test the Taskbar icon/shortcut yet.

  • Reopen the properties of the shortcut and delete the path to explorer in the Target field.

  • Save and close with OK.

You're done.
You can now test your Taskbar Icon/Shortcut.

Conclusion

Congratulations, you tricked Windows to mind its own business.

One note before we part. The icon on the taskbar will launch ComfyUI , but the process will run inside a separate CMD window. The icon only works as a launcher.

7

Comments