-2

I have a program which is supposed to create a listing in the Spacetree through additions.

Almost everything is working fine, but my icon isn't showing.

This is the code which is setting the icon:

reg add HKCU\Software\Classes\CLSID\{5107667c-149a-47c8-b0c9-e4bf9132f17d}\DefaultIcon /ve /t REG_EXPAND_SZ /d "%Program Files (x86)%\PowerFolder.com\PowerFolder\PowerFolder.exe", /f
  1. [Full Code]: https://puu.sh/DUhZz/ac147be668.bat
  2. [Missing Icon]: https://i.stack.imgur.com/sV3hh.png
  3. [How the Icon should look like]: https://i.stack.imgur.com/wWsMN.png

What could be the problem?

Compo
  • 36,585
  • 5
  • 27
  • 39
  • Hi and welcome to SO! Can you please post the relevant bits of your code into your question? – party-ring Jul 18 '19 at 11:10
  • 1
    I did, I've posted the code which is supposed to create the Icon, but it didn't work – Bengalo1412 Jul 18 '19 at 11:19
  • I've marked it in a Screenshot for you https://i.imgur.com/SuPRCao.png – Bengalo1412 Jul 18 '19 at 11:22
  • It is clear from your posted code and the external complete content that you have an unexpected additional character on that line, a comma! If it is supposed to be there, can you explain why? otherwise delete it or add the missing number which usually follows it and include both that and the comma within the doublequotes for that data value! – Compo Jul 18 '19 at 11:33
  • Yeah thanks! I removed it but it's still not working, maybe theres something else? https://i.imgur.com/N4CgsHZ.png – Bengalo1412 Jul 18 '19 at 11:38
  • 2
    I'd expect the command to look a little more like this, `Reg Add "HKCU\Software\Classes\CLSID\{5107667c-149a-47c8-b0c9-e4bf9132f17d}\DefaultIcon" /VE /T REG_EXPAND_SZ /D "%%ProgramFiles(x86)%%\PowerFolder.com\PowerFolder\PowerFolder.exe,0" /F` where the last number, currently `0` would be the icon index from within that resource. If you do not need the number, that's fine, but you really should correct your invalid variable `%Program Files (x86)%` to `%ProgramFiles(x86)%` for a string value, or more correctly, `%%ProgramFiles(x86)%%` for an expandable string as intended. – Compo Jul 18 '19 at 12:04
  • Great! It works now, big thanks ^^ life savior https://i.imgur.com/66pXG5L.png – Bengalo1412 Jul 18 '19 at 12:10

1 Answers1

0

I would expect the line to look a little more like this:

Reg Add "HKCU\Software\Classes\CLSID\{5107667c-149a-47c8-b0c9-e4bf9132f17d}\DefaultIcon" /VE /T REG_EXPAND_SZ /D "%%ProgramFiles(x86)%%\PowerFolder.com\PowerFolder\PowerFolder.exe,0" /F

The 0 in ,0 should be the respective icon index number for that particular resource. If you do not need one, please remove the comma and number suffix:

Reg Add "HKCU\Software\Classes\CLSID\{5107667c-149a-47c8-b0c9-e4bf9132f17d}\DefaultIcon" /VE /T REG_EXPAND_SZ /D "%%ProgramFiles(x86)%%\PowerFolder.com\PowerFolder\PowerFolder.exe" /F

You'll note that you're setting the data type as REG_EXPAND_SZ which means that the data should contain a variable to be expanded when required. If you do not require that feature, you should use a data type of REG_SZ, (which is the default and does not need to be stipulated in your command), and reduce the doubled percents to expand the variable during the addition of the data:

Reg Add "HKCU\Software\Classes\CLSID\{5107667c-149a-47c8-b0c9-e4bf9132f17d}\DefaultIcon" /VE /D "%ProgramFiles(x86)%\PowerFolder.com\PowerFolder\PowerFolder.exe" /F
Compo
  • 36,585
  • 5
  • 27
  • 39