Taskbar icon for all users - windows-7

is it possible to create taskbar icons (shortcuts, shell links, whatever you want them to be named) in the installer in Windows 7? I know this is not possible with the quick launch toolbar in previous windows version, but maybe something has changed in windows 7?

I'm assuming you want to pin an icon to the taskbar. No, that is not programmatically possible, and with good reason. It is your user's job to decide if your program is cool enough that they want it to be pinned to the taskbar.
If this is a corporate environment, note also that there is no group policy setting to affect a pinned item. If you Google around, there are some dirty hacks to get things pinned to the taskbar, but it involves overwriting all of the user's currently pinned items, which is a very bad idea. (I can see the helpdesk calls: "Where did my icons go??? I can't start the internet!")

Yes, it is possible through a VBScript to pin for the current user
http://www.codeproject.com/Articles/185512/Programmatically-PIN-shortcut-onto-Taskbar-on-Win7.aspx
This script can also be created at runtime by this C# .NET Class:
http://blog.ananthonline.net/?p=37
If you are an OEM you can pin to all users during the DASH process with the following command
Reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\TBDEn /v SBOEM0 /t REG_EXPAND_SZ /d “SomeFile.lnk” /f

Windows 7 taskbar pinned icons are stored in the following locations:
File System: %APPDATA%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar
Registry: [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband]
To deploy a pinned item, you can perform the following steps:
Configure Pinned items on a Windows 7 system as a reference computer.
Export Registry Key to pinned.reg file:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband]
And copy items in the %APPDATA%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar to a shared folder.
Create a logon script to deploy the registry keys and copy the corresponding files.
Please note that the %APPDATA%\Microsoft\Internet Explorer\Quick Launch\User Pinned folder is only created after a user has pinned an icon to the taskbar. In the logon script, you will need to create the %APPDATA%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar folder if it does not exist.
PLEASE ALSO NOTE THIS REPLACES ALL ICONS CURRENTLY IN LOCATION!!! So, for me, this is suitable as it is only being used on our DR terminals where the users shouldn't be trying to personalise anything and are going to be moving from terminal to terminal on demand.
Finally: There is another way to do it using this VBS script, which allows you to add to the users current collection of pinned items:
http://blogs.technet.com/b/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx
I didn't like this method as it involves a logon script.

There is no api available to pin an application to the taskbar because Microsoft doesn't want you to do that.
http://msdn.microsoft.com/en-us/library/dd378460(v=VS.85).aspx#unified

Related

Create windows process to delete any unwanted icons from the desktop?

IT has a process hidden somewhere deep on my system which automatically creates certain icons and shortcuts on my desktop if they do not exist. (It may even exist solely on their systems, connecting to mine periodically to do this.) This means when I try to delete them, they are back within a couple of hours. This drives me nuts. I have all of the shortcuts and icons on my taskbar, and do not like having random crap on my desktop.
I would like to write something to run as a service which monitors the desktop every second or so, and deletes anything that shows up.
How would I go about doing this? In a relatively easy and straightforward manner? Would I use a bat file, or vbs script? How do I create a bat file to run as a service?
If you have the "Hide protected operating system files" setting on (it is by default) you could try to just hide the icons with ATTRIB +R +S +H "annoyingapp.lnk".
You can't just run anything as a service. You could perhaps use the Srvany tool to execute your script but I would imagine a task that runs every now and then is a better fit for this issue.

Open folder on portable device with batch file

General goal: create a desktop shortcut to a folder buried the file structure of my phone's SD card (connected via USB). Note, this is on a work computer, so I can't do anything to crazy.
I tried using normal shortcuts to no avail, so I decided to try using a batch if I can't use a shortcut. If using a shortcut is possible or there is a better option than a batch let me know.
Specific question: How can I open a folder using a batch file? I can manually open explorer, paste the address into the bar and go there, so there should be a way to mimic this, but so far my attempts have been unsuccessful.
Attempts:
%SystemRoot%\explorer.exe "Computer\My S4\Phone\Android\data\com.dropbox.android\files\scratch\"
explorer Computer/My S4/Phone/Android/data/com.dropbox.android/files/scratch
start "" "Computer\My S4\Phone\Android\data\com.dropbox.android\files\scratch\"
start Computer\My S4\Phone\Android\data\com.dropbox.android\files\scratch
This is an addition to Andry's answer:
It can be very complicated to get the whole path to an MTP folder like
::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_03de&pid_21e7&mi_00#6&a5ebb37&1&0000#{6ac27878-a6fc-2155-ea85-f98f491d4f33}\{E4FC4EA5-FFFF-FFFF-0000-000000000000}
To get the path do the following:
In Windows Explorer select the folder on the MTP device you want to get the path of.
Open it's context menu and select Copy
Open in Explorer a folder on your PC, open the context menu on a free area and select Paste Shortcut
Now we need a too that can read .lnk files. I have used the tool LECmd. Execute LECmd.exe -f <path to the .lnk file created in step 3>.
You will get a lot of content printed to the console. The interesting part is the Parsing Path next to the end.
In my case it was ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_03de&pid_21e7&mi_00#6&a5ebb37&1&0000#{6ac27878-a6fc-2155-ea85-f98f491d4f33}\SID-{10001,,21003612160}\{E4FC4EA5-FFFF-FFFF-0000-000000000000}
Now we are close, unfortunately the path shown above can not be used because it contains an invalid part: \SID-{10001,,21003612160}. Remove that part and you can open the explorer in that MTP folder using
start "" "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_03de&pid_21e7&mi_00#6&a5ebb37&1&0000#{6ac27878-a6fc-2155-ea85-f98f491d4f33}\{E4FC4EA5-FFFF-FFFF-0000-000000000000}"
There is a way to open an MTP device folder directly in the Windows Explorer window on Windows 7 x64.
Here is steps:
Open Windows Explorer with the My Computer folder, for example:
start "" "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
start "" "shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
explorer "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
explorer "shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
The complete list of GUIDs you can find on the internet, for example: https://www.tenforums.com/tutorials/3123-clsid-key-guid-shortcuts-list-windows-10-a.html
Attach the MTP device and enable File Transfer mode in the device. It must be shown in the My Computer window as a portable device entry.
Drag and Drop the MTP device entry icon to the Desktop.
Open any notepad, for the instance, Windows notepad: Win+R -> notepad
Drag and drop the desktop icon into notepad window.
At the end of the notepad text would be something like:
::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_0e8d&pid_201d&mi_00#7&1084e14&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33} (spaces removed).
You can cleanup the spaces between characters by copy the string into another instance of the notepad and replace them through the Ctrl+H to nothing.
Now you can open the MTP device folder directly:
start "" "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_0e8d&pid_201d&mi_00#7&1084e14&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}\<your-local-path-to-folder>"
There is a wait timeout, so the Windows Explorer window might not open immediately.
To generate a shortcut to target folder you can use make_shortcut.vbs script from here: https://github.com/andry81/contools/tree/HEAD/Scripts/Tools/ToolAdaptors/vbs/
For example:
>
make_shortcut.vbs myphonecamera.lnk "shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_0e8d&pid_201d&mi_00#7&1084e14&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}\SD-card Samsung\DCIM\Camera
Now you can click myphonecamera.lnk to open the folder or use the Windows Explorer:
>
explorer myphonecamera.lnk
Instead of using Computer which is not a device name, try to use \\?\ or \\.\ which both refer to the local computer.

SHGetPropertyStoreForWindow - How to set properties on existing System.AppUserModel.ID

So I split my window from the main tab group via IPropertyStore via SHGetPropertyStoreForWindow like so:
IPropertyStore_SetValue(pps, PKEY_AppUserModel_ID.address(), 'Contoso.Scratch');
pps->Commit();
Then the user later decides he wants to rename it so with my feature he does:
IPropertyStore_SetValue(pps, PKEY_AppUserModel_RelaunchCommand, customLaunchPath);
IPropertyStore_SetValue(pps, PKEY_AppUserModel_RelaunchDisplayNameResource, 'my first name');
pps->Commit();
This works successfully for the first time. But if he wants to change just the RelaunchCommand and RelaunchDisplayNameResource again it won't work unless I change the ID as well.
I gave RelaunchCommand and RelaunchDisplayNameResource as exmple here, in my real case scenario the user ALSO wants to change the icon but the same issue, it works a first time per ID. Anyway to run multiple times without having to change ID every time?
Thanks
PS:
The other big reason for this solution, is that one of my windows already has a System.AppUserModel.ID and is already pinned. I want to just change the icon/relaunchCommand/etc, if i change the System.AppUserModel.ID then it will effectively unpin it. :(
The solution to this topic is the workaround I am using:
Detecting Application Pin State
Before setting property I test if it's pinned by looking in folders of:
%AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned\ImplicitAppShortcuts
%AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar
And I do a IPropertyStore::getValue on all the shortcuts, if it matches my AppUserModelID, then I change the icon, label, etc on that, which right away updates it in the taskbar.
This works but I'll leave this solution unaccepted as it's not documented so probably not the right way to go about it.
If the AppUserModel.ID is not found among the shortcuts, the i just to IPropertyStore::setValue on the windows of my application (I have to do on each window, i cant find a way to do it across the whole application)

Register program on windows registry so that it appears on "Uninstall a program" on Control Panel

Let's say I have a simple program: SomeProgram.exe and Uninstaller.exe those programs are in C:\ProgramFiles\MyProgram along with several dll's and resources.
Anyways I have a simple installer that installs several prerequisites to that path. Now my question is how can I register SomeProgram.exe on window registry so that I can have it appear in add or remove programs in control panel. I will like to execute Uninstaller.exe when the user clicks on remove my program. Also I will like to create a folder on windows startup menu so that the user can start the program from there in case he does not want to have a shortcut on the desktop.
All you need to do is to create the registry entries as documented in the second link from "sergmat". This will make the program to appear in the list from Control Panel.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa372105(v=vs.85).aspx

Disable all shared folder

What is the CMD Command to Disable the All share folder on the Win XP machines.
Thank You
Deliver command in this sequence
net share
This will enlist all the shared resources
net share DataShare /delete
where datashare is the choice you want to remove
http://technet.microsoft.com/en-us/library/bb490712.aspx
(For Win10)
1- Run cmd.exe as administrator
2- wmic path Win32_Share delete
Try the next steps:
Click Start, then right-click Computer, and then click Manage.
In the console tree, click System Tools, then click Shared Folders, and then click Shares.
In the details pane, right-click a shared folder, and then click Stop Sharing (this item only appears if you launched Computer Management using an account that is a member of the local Administrators group).
To stop sharing multiple files, press the CTRL key while clicking the file names, right-click any one of the selected files, and then click Stop Sharing. This removes shared network access to the selected files.
https://technet.microsoft.com/en-us/library/cc753475(v=ws.11).aspx
wmic path Win32_Share delete
(tested on win10)
Not sure about the cmd command and if you want to automate it.
But if it's a 1 time thing you need to do you can always run mmc.exe and add the Shared Folders snapin via File/Add Remove snap-in.
In this screen you will get a list of all your shares and you can disable them as needed.

Resources