PinTo10v2

Very much a place-holder for now but I thought my Windows command-line tool PinTo10v2 could do with a home page…

A lot of IT admins will know that the popular VB Script that pins items to the Windows 7 Task Bar and Start Menu does not work in Windows 10.  I made PinTo10 about 18 months ago based on the Nullsoft Scriptable Installer framework which was functional but slow and heavy for a command-line tool and not really the right tool for the job at all.  Now, based on some great work by Alex Weinberger ( http://alexweinberger.com/main/pinning-network-program-taskbar-programmatically-windows-10/ ), I’ve made PinTo10v2 which has the same functionality as the original but is a fraction of the size and far more efficient. The source code isn’t very pretty as I’m no c# coder (I normally stick to basic scripting) but it works.

Give it a go, source code included…

https://www.dropbox.com/s/q4joxy231hz0klj/PinTo10v2_1.1.zip?dl=1

Stuart Pearson

 

 

Advertisements

32 thoughts on “PinTo10v2”

    1. Rob, Sadly not. This method still uses the verb method (with a little modification for it to work on Windows 10 thanks to Alex Weinberger). As the default pinning of Edge doesn’t seem to actually directly link to a .lnk or .exe that verb can’t be triggered. The best methods available at the moment seem to be importing a set of registry keys to HKCU for a basic “taskband” and restarting explorer.exe. Then you can pin whichever icons you want back. It’s not pretty but it’s probably the best solution at this point in time.

      Like

    2. I was still able to unpin with the old vbscript method just unable to pin so for edge you could use something along the line of

      Set sho = CreateObject(“Shell.Application”)

      sourcedir = fso.GetFile(WScript.ScriptFullName).ParentFolder
      Set folder = sho.Namespace(“shell:AppsFolder”)

      For Each item In folder.Items
      If contains(item.Name,”Microsoft Edge”) Then
      Set folderItem = folder.ParseName(item.Path)
      folderItem.InvokeVerb(“taskbarunpin”)
      End If
      Next

      Function contains(sourceStr, checkStr)
      contains=InStr(1, sourceStr, checkStr, vbTextCompare) > 0
      End Function

      Like

      1. Stefan,
        You absolutely rock!!!

        I did a quick test of this vbs script on a Win10 1703 and it removed Edge. I tweaked it to remove Store and Mail from the taskbar and it removed those too. I’m not sure why this works when the “Pin to taskbar” verb was supposed to be removed from being able to be scripted. But, hey, it works!

        Stuart, I cannot forget your work either. Your utility helps me immensely in scripting the addition of customer-requested items to the taskbar and start menu.

        Between both of your efforts, you have both made my customization and deployment of Win10 that much easier.

        Thanks!!!

        Like

      2. I am not the author or anything so maybe I misinterpret the code but I think for modern apps where you would have to use their AppUserModelID to call them the method that tricks windows into thinking the pinning verb is present might not work. So the most simple workaround would be to create a shortcut to the app (the app can be found in shell:AppsFolder with the Path being the AppUserModelID) So you could use a code like the one I posted above and then create a shortcut where it doesn’t hurt you (for example in the start menu). For this you have to add shell:AppsFolder\ in front of the path (so something like:

        Set lnk = wso.CreateShortcut(“C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Edge.lnk”)
        lnk.TargetPath = “shell:AppsFolder\” & item.Path
        lnk.Save

        within the if in my code)
        Then you can pin and unpin with the lnk as a the target. (This would also work as alternative method for unpinning, but you need to create the shortcuts programatically (alternatively you could also try to create them once by hand and then copy them to you system thus getting rid of the scripting)

        Like

      3. thanks
        Just had to create a lnk file and point the path shellappsfolderwindowslivemail Etc but unfortunately you have to use a custom icon which I used shell32.dll,156

        Like

      4. Hello Stefan,

        Thanks for the vb script. However, when I try to run your script (exactly as posted above), I get an error :
        Line: 3
        Char: 1
        Error: Object Required: ‘fso’
        Code: 800A01A8
        Source: Microsoft VBScript runtime error

        I’m not programmer, but I see that fso is not defined and can only assume that’s what it’s complaining about? I’d appreciate any assistance in getting this to run.

        Thanks,
        Brett

        Like

  1. Hello Stuart
    What is the reason that your (very nice) tool doesn’t work on Server OS, for example Server 2016?
    Ever since I discovered this tool we’ve been using it for our Windows 10 deployments. Now I wanted to also use it for Server 2016 but apparently it’s not supported.

    Like

    1. Hi Mike,

      Only Windows 7 and 10 are supported because those are the OS’s that have been tested and are known to work. This is why I’ve provided the source code for it.

      If you look at line 71 of Program.cs you’ll see that it exits the program if it doesn’t detect Windows 7 or 10. You should simply be able to change that line from…

      Environment.Exit(0);
      to
      actionIndex = pin ? 51201 : 51394;

      and then recompile it.

      This should work (completely untested)…
      https://www.dropbox.com/s/tewwil1axsovxa8/PinTo10v2_NoOSCheck.zip?dl=1

      Stuart

      Liked by 2 people

      1. So is the correct syntax something like this:

        PinTo10v2_NoOSCheck.exe /pintb ‘paint.net’
        -or-
        PinTo10v2_NoOSCheck /pintb ‘C:\Program Files\paint.net\paintdotnet.exe’
        -or-
        PinTo10v2_NoOSCheck /pintb ‘C:\Program Files\paint.net\paintdotnet.lnk’

        Thanks

        Like

      2. Hi,

        Either…

        PinTo10v2_NoOSCheck /pintb “C:\Program Files\paint.net\paintdotnet.exe”
        -or-
        PinTo10v2_NoOSCheck /pintb “C:\Program Files\paint.net\paintdotnet.lnk”

        … should work as long as the file exists. Full paths are needed (although I appreciate that I only put “filename” in the help file.

        Please note that the NoOSCheck might operate differently or not at all on OS’s that are not Win 7 or 10 so if something isn’t working (and you’re not using Win 7 or 10) then please try it on a “supported” operating system first.

        Stuart

        Like

  2. Stuart: I know the source is included, but could you include a license statement to clarify how your (nice) work can be used? Thanks.

    Like

    1. Feel free to link back to this site and this statement. I’m no lawyer and don’t know how open source really works but I am providing the compiled exe and source code available to everyone to use with no suggestion that this is fit for purpose or comes with any expression of support or warranty. Please use at your own risk. I have tested it and know it to work as I intended. As it is based on someone else’s source code you would have to also check that they are also happy for the code to be used.

      Like

  3. Hi There

    Is it possible to add an argument?
    eg
    PinTo10v2.exe /pintb path=”C:\Program Files\FileMaker\FileMaker Pro 15 Advanced\FileMaker Pro Advanced.exe” arg=”\\domain\share\FILETOOPEN.fmp12″

    Like

  4. Hey there, I have used this tool 2 times until now and it all worked fine until now. I am trying to pin a folder link (same happens with and .exe or application link) to the start menu of Windows 10 1607 (via CMD command, but it gives the same error with PS as well) and it fails with the following description:
    Unbehandelte Ausnahme: System.UnauthorizedAccessException: Der Zugriff auf den Pfad “C:\ProgramData\Microsoft\Windows\Start Menu\Programme” wurde verweigert.
    bei System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
    bei System.IO.FileSystemEnumerableIterator`1.AddSearchableDirsToStack(SearchData localSearchData)
    bei System.IO.FileSystemEnumerableIterator`1.MoveNext()
    bei System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
    bei System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption searchOption)
    bei PinTo10v2.Program.Main(String[] args)

    I would appreciate any help.
    Thanks!

    Like

    1. Hi, support will be quite minimal (if any) but do you have the command line you’re trying to run?

      I didn’t test any folder shortcuts but looking at them then I think pinning them to the Start Menu may work but the verb to pin them to the taskbar doesn’t appear to be there by default. I also have no idea if this will work in any language than US / UK which is why I’ve provided the source.

      If you look at line 122 of Utils.cs you will see that it’s hard-coded to look at…
      string currentuserstart = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @”\Microsoft\Windows\Start Menu\Programs”;

      I would guess that the folder %APPDATA%\Microsoft\Windows\Start Menu\Programs doesn’t exist on a German system? This can be changed to whatever it should be and re-compiled in Visual Studio. Whilst you’re at it you could also fix a bug on line 233 of the same file which is currently…
      counter = counter = + 1;
      but should be…
      counter = counter + 1;

      As it stands it can go into an infinite loop.

      Hope this is of some help.

      However…

      The way I’m working on my deployments for this summer is going to be based on the update of a Powershell Cmddlet for applying a default Start Menu menu to new user to include the default TaskBar…

      https://sccmguru.wordpress.com/2016/08/18/windows-10-1607-taskbar-and-start-customization-deep-dive/

      Stuart

      Like

  5. Hi,
    I will look into it and get back with some results. I actually never used VS until now, but I will learn, not a problem.
    The reason for trying to use your app, is that in 1607 the XML does not pin Folders, and my Customers have that as a requirement.

    The command line for pinto I use is:
    path to pinto exe /pinsm “path to shortcut”
    Indeed I have tested it on US MUI and it works, so what do you suggest I do to add support for other languages, because my Customers are multinational, including Japanese and Chinese?

    I am following the other blog as well!

    Thanks.

    Like

    1. Hi, if you modify the start menu path to point at special folder “startup” and traverse up a folder from there you will get the startmenu > programs from there on 100% of international OSes. BTW this app works on server 2012 and server 2016. I wish it could run faster but I am using it at our school to pin many things including control_panel>printers with windows 10 and it works very well, good job!

      Like

    1. You can look in the user’s directory to see which Win32 apps are pinned to the TaskBar…
      %APPDATA%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar

      Not so easy to check for items already pinned to the Start Menu. The only way I can think of would be to check all .lnk files in the start menu to see if the verb for “Unpin from Start” is present. This would probably be a relatively lengthy process and, again, won’t work for modern apps.

      Like

    1. This might be useful…
      http://stackoverflow.com/questions/14899422/how-to-navigate-a-few-folders-up
      https://msdn.microsoft.com/en-us/library/system.environment.specialfolder(v=vs.110).aspx

      Presumably you could use something like this to work for all languages (completely untested)…

      string currentuserstart_ = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
      string currentuserstart = Path.GetFullPath(Path.Combine(currentuserstart_, @”..\”));

      Like

  6. Hi. Great tool but not correctly works with explorer.exe

    What do I mean?

    1. PinTo10v2.exe /pintb “%windir%\explorer.exe” – Explorer shortcut pins to taskbar, everything works fine
    2. PinTo10v2.exe /pintb “%windir%\explorer.exe” – Explorer shortcut renames to Explorer(2) in folder %appdata%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar and shortcut on taskbar doesn’t work
    3. PinTo10v2.exe /pintb “%windir%\explorer.exe” – no reaction
    4. PinTo10v2.exe /pintb “%windir%\explorer.exe” – no reaction
    5. PinTo10v2.exe /pintb “%windir%\explorer.exe” – no reaction
    etc
    The only way to fix it is right- click on Explorer shortcut in taskbar and select “unpin”.

    Other files, f.e. write.exe (WordPad) greatly work with this tool, no matter how times you execute command.

    Can you fix it?

    PS
    I’m using Windows10 LTSB (special corporate edition)

    Like

    1. Running Win 10 Enterprise 2015 LTSB 10.0.10240, V2 just hangs when run as described above. Guessing some patch (enhancement) is blocking the script.

      Anyone seeing this.

      Like

      1. To get around just create the shortcuts first eg

        batch.cmd
        call :shortcut “%temp%” “Explorer” “c:\windows\explorer.exe”
        call :shortcut “%temp%” “Mail” “c:\windows\explorer.exe” “c:\windows” “shell:AppsFolder\microsoft.windowscommunicationsapps_8wekyb3d8bbwe!microsoft.windowslive.mail” “C:\Windows\System32\SHELL32.dll, 156”
        call :shortcut “%temp%” “Print Server” “c:\windows\explorer.exe” “c:\windows” “\\PrintServer” “%SystemRoot%\system32\shell32.dll,60”
        call :shortcut “%temp%” “Devices and Printers” “c:\windows\explorer.exe” “c:\windows” “shell:::{A8A91A66-3A7D-4424-8D24-04E180695C7A}” “%systemroot%\system32\DeviceCenter.dll”
        call :shortcut “%temp%” “logoff” “C:\Windows\System32\shutdown.exe” “C:\Windows\System32” “/l” “C:\Windows\System32\SHELL32.dll, 25″

        :shortcut
        set _vbs=”%temp%\_.vbs”
        if exist %_vbs% del /f /q %_vbs%
        >%_vbs% echo set objShell = CreateObject(“WScript.Shell”)
        >>%_vbs% echo sLinkFile = %1 ^& “\” ^& %2 ^& “.lnk”
        >>%_vbs% echo Set oLink = objShell.CreateShortcut(sLinkFile)
        if “%~3” neq “” echo oLink.TargetPath = %3>>%_vbs%
        if “%~4” neq “” echo oLink.WorkingDirectory = %4>>%_vbs%
        if “%~5” neq “” echo oLink.Arguments = “”%5″”>>%_vbs%
        if “%~6” neq “” echo oLink.IconLocation = %6>>%_vbs%
        >>%_vbs% echo oLink.Save
        cscript //nologo %_vbs%
        “%~dp0PinTo10v2_NoOSCheck.exe” /pintb “%temp%\%~2.lnk” >nul
        exit /b

        Like

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