• Create your own Control Panel Applet(s)

    Home » Forums » AskWoody support » Windows » Windows 7 » Questions: Windows 7 » Create your own Control Panel Applet(s)

    Author
    Topic
    #494174

    I’ve been configuring a Windows 7 laptop for my sister to replace her old Windows XP one now that OS support is ending. On the old laptop I had used J S Payne’s CPL Maker to create some Control Panel Applets to run several of my favourite utilities.

    The advantages of having utilities called from the Control Panel are:

      [*] Shortcuts on the Windows desktop or Start menu cannot be renamed or deleted (for example, by her children).
      [*] As a result, when I’m on the phone to her I know the exact name and location of the utility I’m asking her to run.
      [*] There’s no ‘un-install’ option visible. (I delete any Start menu shortcuts to any uninstallers.)
      [*] The Control Panel Applet is visible to all users and, if I want, I can get it to only appear in certain Control Panel categories.
      [*] If there are a lot of applications installed then it’s often quicker for someone to find a CPL applet then scroll down a long list in a Start menu.

    Unfortunately I soon found that CPL Maker doesn’t work with Windows 7. I knew it must be possible after seeing the Flash Player and Java Control Panel Applets that are added by their installation. I looked around and, on MSDN, found How to Register Executable Control Panel Items. The article looked complex but I soon found that it was actually incredibly easy to create a very simple registry (.REG) file that did what I wanted.

    In case it’s useful to you, I thought I would document the steps:

    First, a slight caution. It’s not exactly a warning ‘cos you aren’t going to be deleting any information from the registry nor amending any existing information, only adding 2 registry keys (and a couple of sub-keys) to describe your new Control Panel applet. However, it IS the registry so, for safety’s sake, back it up by creating a Restore Point:

    1. Click on the Start orb and enter Create a restore point in the Search programs and files text box.
    2. Click on Create a restore point when it appears in the results list.
    3. Click on the Create… button at the bottom of the dialog that appears. (Alternatively, click on Start > Control Panel > System > System Protection [in the left pane] to get to the same dialog.)
    4. Type a description (e.g. My custom CPL applet) then click on the Create button.
    5. Click on the Close button to dismiss the confirmation dialog then on the OK button to dismiss the System Properties dialog.

    Here are the 3 basic steps to create a new Control Panel Applet:

    1. Create a GUID. (GUID is an acronym for ‘Globally Unique Identifier‘, i.e. a unique reference number.)
    2. Depending on the ‘bitness’ of your utility and OS, use one of the attached .REG files and open it in Notepad.
    3. Amend the details in the .REG file then save the changes using a new filename.

    All you have to do now is double-click on the .REG file (and click on the Yes, Yes and OK buttons that appear) to merge the new information into the registry. Open the Control Panel and the new applet for your utility should now be visible. It really is that easy… just make sure you use the right .REG file:

    x32-in-x32-cpl.reg for a 32-bit utility running in a 32-bit OS,
    x86-in-x64-cpl.reg for a 32-bit utility running in a 64-bit OS.
    x64-in-x64-cpl.reg for a 64-bit utility running in a 64-bit OS.
    (Note: The forum uploader doesn’t allow the attachment of .REG files so I’ve had to rename the file extensions to .TXT. Download them and rename the file extensions back to .REG.)

    I decided to add TeamViewer 9 Quick Support as a Control Panel applet. Here are the steps in greater detail:

    1. I downloaded TeamviewerQS. This is a 32-bit standalone utility (i.e. it doesn’t need to be installed) and will be running in a 64-bit version of Windows 7 so I created a folder in C:Program Files (x86) and moved the utility into it (and renamed it from “TeamViewerQS_en.exe” to “TeamViewer9_QuickSupport.exe” to make it clearer what version it is).
    2. I used a copy of x86-in-x64-cpl.reg and opened it in Notepad.
    3. I used Online GUID Generator to create a new GUID. I put a tick in the Uppcase and Braces checkboxes then clicked on the button to generate an uppercase GUID in the same format used in the Windows Registry.
    4. I copied the new GUID and pasted it several times into the file opened in Notepad, making sure I overwrote all the existing GUIDs.
    5. I amended the name of the utility and its location then saved the changes to the .REG file using a filename describing the new CPL applet, e.g. teamviewer-qs-cpl.reg.

    After double-clicking on the .REG file and accepting the changes, voilà… the new Control Panel applet (plus a few others I created for some of Nir Sofer’s excellent utilities):

    Note: If you get a message that the import failed after double-clicking on the .REG file then it’s most likely you are logged in to a user account with reduced rights. In this case, click on the Start orb, type regedit in the Search programs and files text box then, when regedit appears in the results list, right-click on it and choose Run as administrator. Click the Yes button in the UAC dialog then, when the Registry Editor opens, use File > Import… to merge the .REG file.

    That’s about it… except, if you want to control the CPL categories that your applet appears in, have a look at Assigning Control Panel Categories. I always change the view of Control Panel to Small icons so I always leave the category setting at 0. However, if I did use Category view and wanted my TeamViewer applet to appear in both the “Network and Internet” and “Programs” categories then I would have changed the following line:
    “System.ControlPanel.Category”=”0”
    to:
    “System.ControlPanel.Category”=”3,8”

    If you want to remove your custom Control Panel applet, do the following:
    1. Open the .REG file you created for your applet.
    2. Delete the sub-keys and values, leaving only the 2 main keys.
    3. Add a hyphen behind each of the two opening square brackets.
    4. Save the .REG file with a different filename, e.g. remove-teamviewer-qs-cpl.reg.

    Before

    Code:
    Windows Registry Editor Version 5.00
    
    [HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionexplorerControlPanelNameSpace{7A3972A1-1BCA-4FA1-873A-CD508E2DA075}]
    @=”TeamViewer 9 Quick Support”
    
    [HKEY_CLASSES_ROOTCLSID{7A3972A1-1BCA-4FA1-873A-CD508E2DA075}]
    @=”TeamViewer 9 Quick Support”
    “InfoTip”=”@C:\Program Files (x86)\Teamviewer\TeamViewer9_QuickSupport.exe”
    “System.ApplicationName”=”TeamViewer 9 Quick Support”
    “System.ControlPanel.Category”=”0″
    
    [HKEY_CLASSES_ROOTCLSID{7A3972A1-1BCA-4FA1-873A-CD508E2DA075}DefaultIcon]
    @=”C:\Program Files (x86)\Teamviewer\TeamViewer9_QuickSupport.exe”
    
    [HKEY_CLASSES_ROOTCLSID{7A3972A1-1BCA-4FA1-873A-CD508E2DA075}Shell]
    
    [HKEY_CLASSES_ROOTCLSID{7A3972A1-1BCA-4FA1-873A-CD508E2DA075}ShellOpen]
    
    [HKEY_CLASSES_ROOTCLSID{7A3972A1-1BCA-4FA1-873A-CD508E2DA075}ShellOpenCommand]
    @=”C:\Program Files (x86)\Teamviewer\TeamViewer9_QuickSupport.exe”
    
    

    After

    Code:
    Windows Registry Editor Version 5.00
    
    [-HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionexplorerControlPanelNameSpace{7A3972A1-1BCA-4FA1-873A-CD508E2DA075}]
    
    [-HKEY_CLASSES_ROOTCLSID{7A3972A1-1BCA-4FA1-873A-CD508E2DA075}]
    
    
    

    After double-clicking on this new .REG file and accepting the changes your custom applet will disappear from the Control Panel. (Note: This only removes the applet, not the utility itself.)

    Hope this helps…

    Viewing 1 reply thread
    Author
    Replies
    • #1491714

      This is nice tips, but I can”t find the reg files? Where are they?

    • #1491936

      Hi viettungvuong – Re-using .reg files and an Online GUID Generator was always a bit ‘kludgy’ so I wrote an AutoHotkey script that generates a new GUID then creates a new .reg file based on whatever executable file you point a file selector at.

      Creating the script was made much easier when I discovered – during testing with both 32-bit and 64-bit versions of Windows 7 – that Windows doesn’t care whether you use the 64-bit version of the namespace as long as you get the file location of the target executable correct for the ‘bitness’.

      For example:

      Code:
      HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionexplorerControlPanelNameSpace

      works just as well as:

      Code:
      HKEY_LOCAL_MACHINESOFTWARE[B]Wow6432Node[/B]MicrosoftWindowsCurrentVersionexplorerControlPanelNameSpace

      This meant that I could dispose of 3 different versions of .reg files (x32-in-x32-cpl.reg, x86-in-x64-cpl.reg and x64-in-x64-cpl.reg) and just automate the creation of a single .reg file for all situations.

      Here’s the AutoHotkey script:

      Code:
      ; Thanks to AutoHotkey Community member Ferry for the GUID creation (http://www.autohotkey.com/board/topic/78512-generate-guid/#entry498781)
      ; Thanks to AutoHotkey Community member Garry for sorting the GUID parsing (http://ahkscript.org/boards/viewtopic.php?f=5&t=5293)
      TypeLib := ComObjCreate(“Scriptlet.TypeLib”)    
      GUID := TypeLib.Guid
      guid=%guid%
      guidx=
      StringSplit,a,guid
      Loop,%a0%
        guidx .= a%A_Index%
      ;GUID = {F076BF16-7996-427B-B767-7F50B583AA7B}  ; For testing purposes
      NewRegFile = %A_ScriptDir%NewCPL.reg
      
      FileSelectFile, SelectedFile, 3,%A_ProgramFiles%, Open a file, Programs (*.exe)
      
      if SelectedFile =
          {
          MsgBox, The user didn’t select anything.
          Exit
          }
      else
          {
          SplitPath, SelectedFile, name, dir, ext, name_no_ext, drive
          }
      
      StringReplace, Target, SelectedFile, , \, All
      TargetFile := name_no_ext
      StringUpper, TargetFile, TargetFile, T ; Change filemame to title case for display purposes
      
      ;ifexist,%NewRegFile%
        FileDelete %NewRegFile%  ; In case previous run was terminated prematurely.
      
      ifnotexist,%NewRegFile%
      {
      e4x=
      (Join`r`n
      Windows Registry Editor Version 5.00
      
      [HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionexplorerControlPanelNameSpace%GUIDx%]
      @=”%TargetFile%”
      
      [HKEY_CLASSES_ROOTCLSID%GUIDx%]
      @=”%TargetFile%”
      “InfoTip”=”@%Target%”
      “System.ApplicationName”=”%TargetFile%”
      “System.ControlPanel.Category”=”0″
      
      [HKEY_CLASSES_ROOTCLSID%GUIDx%DefaultIcon]
      @=”%Target%”
      
      [HKEY_CLASSES_ROOTCLSID%GUIDx%Shell]
      
      [HKEY_CLASSES_ROOTCLSID%GUIDx%ShellOpen]
      
      [HKEY_CLASSES_ROOTCLSID%GUIDx%ShellOpenCommand]
      @=”%Target%”
      )
      Fileappend,%e4x%,%NewRegFile%
      }
      RunWait notepad.exe %NewRegFile%
      ;run,%NewRegFile%           ;- run textfile
      return

      When you run the script it generates a new GUID on the fly then presents a file selector for you to choose which executable you want. When you’ve chosen an executable the script will then generate a new .reg file for you and open it in Notepad for you to check.

      When I get round to it I might tidy it up a bit to also automatically generate a second .reg file to remove the Control Panel applet again but, to be honest, it’s not a priority as I was only removing the applets during testing.

      You’ll need to download AutoHotkey. I also use SciTE4AutoHotkey for editing AHK scripts.

      I’ve also added a .zip file which includes the script as both a .AHK file and a compiled version.
      39532-Create-your-own-Control-Panel-applets

      Hope this helps…

    Viewing 1 reply thread
    Reply To: Create your own Control Panel Applet(s)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: