A place for spare thoughts

13/06/2011

Troubleshooting: Git Bash icon replaced standard cmd.exe’s one

Filed under: git — Ivan Danilov @ 01:48

Shortly after installing msysgit on my box I saw that my console windows were shown with Git’s icon on the taskbar. Some checking revealed that only 32-bit cmd.exe placed in the SysWOW64 folder had icon replaced. No matter how you run cmd.exe from 32-bit process (namely I run it most often from Total Commander) you see Git’s icon.

After an hour of trials and errors I found that it is due to mere existing of shortcut file in the start menu. Wow!
The shortcut was to Git Bash and it has this line as a Target:
C:\Windows\SysWOW64\cmd.exe /c ""C:\Program Files (x86)\Git\bin\sh.exe" --login -i"
Icon was changed to Git’s one (actually it was the way I discovered this file). When I renamed it to something like “*.lnk_” or changed target to any other executable – cmd.exe obtains its rightful icon back. It’s worth to mention that other places of my hard drive still had links to cmd.exe with Git’s icon, but this fact didn’t influence cmd.exe. Only shortcut in start menu did.

So I decided to check what happens if I would have two shortcuts with different icons there? 🙂 And so I created new shortcut to cmd.exe in the same place. Now cmd.exe has own icon and Git Bash has its icon, everybody is happy.

With some additional experiments I found that which shortcut selected to get icon properties from depends on parameter list in the first place. And if param list of both shortcuts is equal – selection is made by lexical order of shortcuts’ filenames – e.g. if one named a.lnk and another b.lnk – cmd.exe will have icon set in a.lnk.

I don’t understand this behavior of Windows (I have Win7 x64 Ultimate with SP1 installed by the way) but it is as is how EULA explicitly mentions.

Advertisements

8 Comments »

  1. Thanks for the hint! This is such a small thing, but it was really bugging me.
    Can’t imagine how you stumbled across this fix, but it does work.

    Comment by Andy (@andypaxo) — 07/11/2011 @ 23:36

  2. Thanks! That was pretty annoying for me too – it’s OK now thanks to your post.

    Comment by onyman — 13/11/2011 @ 20:38

  3. Thanks Ivan. This helped fix the annoying problem.

    Comment by sk — 01/05/2012 @ 17:48

  4. ty! it really bugged me too : )

    Comment by fter — 09/07/2012 @ 12:59

  5. Just saw this for the first time after upgrading from Windows XP to 7 Enterprise x64. Couldn’t imagine what caused it. Thanks!

    Comment by JM Welch — 24/09/2012 @ 16:28

  6. Thanks, but you should put in two lines what exactly needs to be done to fix the problem for those looking for a quick fix.

    Comment by Pedro — 21/10/2012 @ 20:44

  7. Thank you for your hint – it really helped. This is what I did:
    * in folder C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Git I created new shortcut with command “cmd” and description “cmd – icon replacement”. Since cmd is higher in alphabet than “Git bash”, it worked
    * I restarted the Total Commander

    Comment by ToC — 27/11/2012 @ 11:20

  8. More elegant way to fix it is
    – Create ‘Git bash.bat’ batch file located right in the Git installation folder.
    – Put single command in it:
    @”%~dp0bin\sh.exe” –login -i
    This command does just the same thing as the shortcut
    – And finally redirect target of the shortcut to this batch file (no parameters are required then, as they are hard-coded directly in the batch)

    As soon as you click Apply in the shortcut properties window, you’ll notice your running cmd.exe’s icons restore back to normal in the task bar.

    You can do the same thing for similar shortcats replacing cmd.exe with batch files

    Comment by Alexey — 30/01/2013 @ 07:42


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: