"Dynamic" icons

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
(like the Recycle Bin has)

This post might be of some interest for some people who want to
- create shortcuts with icons that represent the current state (sort of the way widgets work) or
- Enhance Internet security

Starting with the second one, Enhance Internet security

I wanted to get rid of all those "phone home" applications that want to upload telemetrics, open websites after installation or do "evil things". The way I did this:

- Make Internet Explorer /Edge the default browser (I'm using Firefox for browsing, but IE is set as the default browser)

- Configure a dummy, non-existing proxy. Mine is called "DoodSpoor" (which roughly translates to "Dead End").
This is a non-existing proxy, so any application that wants to "phone home" retrieves the default browser settings and then uses the "Doodspoor" proxy to do this. Of course this will not succeed.

- Create exceptions. Otherwise for example Windows Update or Take Command will fail in some or all aspects.
Most internet aware applications have their own configuration options to set (or unset) a proxy.
Other applications can be added to the Internet settings Exception list, like this:

2017-01-17 18_39_43-Internet Properties.png

And that's about it.


If for some reason you want to disable the proxy ( for example for testing or to allow traffic temporarily) you can untick the “Use a proxy server ...” setting in the LAN settings dialog box.

One thing to keep in mind: URL's outside the browser can no longer be double-clicked as it will use the default browser (IE/Edge). Instead drag the URL to your browser(icon) to open it in Chrome/Firefox/....


Create shortcuts with icons that represent the current state

Way too often I forgot to re-enable the proxy after testing, so I was looking for a way to show an icon on the desktop to display the current state of the proxy, just like the Recycle Bin does: it’s icons changes, depending on the empty/full state.
This mechanism turned out to be quite complicated, so I opted for a simpler approach:

– Create a shortcut on the desktop to start DoodSpoor.btm
– Upon starting this btm the current state of the proxy is read from the registry.
– The flipped state (on := off ; off := on) will be written to the registry
– The icon of the shortcut will be changed to match the new state of the proxy.

It is not dynamic in a litteral way, but for this case dynamic enough (this is the only place where I change these proxy settings).
Of course it can be made more dynamic if you have a .btm that keeps reading a state (for example of connection to a certain server or diskusage > 90%). This is just an example.

The code:
DoodSpoor.btm
Code:
@echo off
setlocal

set REGKEY=HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable
set PROXY=%@regquery["%REGKEY%"]

SWITCH %PROXY%
CASE 0
echo %@regset["%REGKEY%",REG_DWORD,1]
SHORTCUT "%_batchname" "" "" "Proxy aan/uit" "%USERPROFILE%\Desktop\DoodSpoor.lnk" 1 "C:\Windows\System32\imageres.dll" 101
CASE 1
echo %@regset["%REGKEY%",REG_DWORD,0]
SHORTCUT "%_batchname" "" "" "Proxy aan/uit" "%USERPROFILE%\Desktop\DoodSpoor.lnk" 1 "C:\Windows\System32\imageres.dll" 100
DEFAULT
SHORTCUT "%_batchname" "" "" "Proxy aan/uit" "%USERPROFILE%\Desktop\DoodSpoor.lnk" 1 "C:\Windows\System32\imageres.dll" 102
ENDSWITCH
EXIT
(Sorry for the missing indentation; don't know what went wrong here)


Results:
Proxy Enabled:
2017-01-18 01_20_04-.png

Proxy Disabled:

2017-01-18 01_20_36-.png

Proxy state unknown:
2017-01-18 01_21_08-.png