Special context menu entry - Howto?

Discussion in 'Operating Systems' started by 386SX, Jun 8, 2019.

  1. 386SX

    386SX Ancient Guru

    Messages:
    2,084
    Likes Received:
    2,243
    GPU:
    AMD Vega64 RedDevil
    Hi all.

    I've got some "problem" where I want to create a special context menu entry to do the following:

    I use a download manager to download files. Because of my 400mbit/s line I figured any HDD would be completely locked doing this with multiple connections per download, so my download path is on some SATA SSD, for example:

    Code:
    X:\downloads\<name of download>\
    
    Because my SSD is not meant as a permanent storage of those files, I've got some scripts in place to copy stuff to my storage drive, some big HDD, for example:

    Code:
    Z:\storage\<name of download>\
    
    My download manager allows me to visit the download folder, but I want to get to the Z drive as fast as possible. So I thought of a simple context menu item to take the current path and open some explorer window at the intended location in Z like:

    Code:
    from:
    X:\downloads\somedownload123\
    
    to:
    Z:\storage\somedownload123\
    
    So the context menu item would have to read the path from where the conext menu is run (right click in download folder) and then open a new Explorer window with Z:\storage\ instead of X:\downloads\ .

    So far I only found third party tools or generic things like adding "COPY TO", but none of them had anything like this feature.

    Does anybody know how to accomplish that?
     
  2. kens30

    kens30 Maha Guru

    Messages:
    1,225
    Likes Received:
    93
    GPU:
    RTX 3070 GAMING OC
    Just create a shortcut to the drive and pin it to the taskbar.

    I just did a quick search in google and I have already created a context menu (sort of) like you described,
    but it involves editing the registry here Computer\HKEY_CLASSES_ROOT\DesktopBackground\Shell

    Sorry but I am just too tired at the moment to describe the whole procedure.:)
     
    Last edited: Jun 8, 2019
    386SX likes this.
  3. Chastity

    Chastity Ancient Guru

    Messages:
    3,744
    Likes Received:
    1,668
    GPU:
    Nitro 5700XT/6800M
    Sounds like this is for torrenting, and many clients already have the ability to copy/move completed torrents to another location. This would allow you to use the SSD as the download buffer, then move it to your final destination automatically.
     
  4. 386SX

    386SX Ancient Guru

    Messages:
    2,084
    Likes Received:
    2,243
    GPU:
    AMD Vega64 RedDevil
    That's not my intention, sorry.

    And no, I don't do torrenting.

    Could we please stay on topic?
     

  5. WhiteLightning

    WhiteLightning Don Illuminati Staff Member

    Messages:
    30,785
    Likes Received:
    3,959
    GPU:
    Inno3d RTX4070
    if you have explorer open , why not use quick access ? you can drag any location to there, and it will pin it.
     
  6. C0D3M4N

    C0D3M4N Member

    Messages:
    30
    Likes Received:
    3
    GPU:
    Asus 1080Ti
    386SX likes this.
  7. kens30

    kens30 Maha Guru

    Messages:
    1,225
    Likes Received:
    93
    GPU:
    RTX 3070 GAMING OC
    Wow 400mbit/s line i can only dream of having those speeds.
    Unfortunately where i live there is only one internet service that provides only up to 24Mbps.
    I only synchronize to 16.50Mbps and i had to wait many hours to re-download Doom 2016
    and Battlefield 5.

    Sorry for going off topic. I want to take full advantage of my download speed so can i ask what download manger you are using that allows multiple connections per download?
     
  8. 386SX

    386SX Ancient Guru

    Messages:
    2,084
    Likes Received:
    2,243
    GPU:
    AMD Vega64 RedDevil
    If checksum / resume / etc. is needed and the source does not change (static URL) I use WGET (if source is from the internet) or ROBOCOPY (within LAN) to transfer backups for example. Both run very well in scripts and have a lot of parameters to filter, for dedup (partially) and stuff.
    For other things I use "JDownloader 2", as it's able to do some checksum functions together with other stuff (add accounts like FTP or passwords to connect or extract files).



    That would result in dozens of pinned items over time, as the sub-dirs change.

    Example:
    I download Win10 1903 to X:\downloads\win10_1903\*.*
    My DL manager allows me to go to X:\downloads\win10_1903\
    My scripts already have copied everything what is not an archive to Z:\datastore\win10_1903\*.*
    The folder I get from my DL manager is empty, as my files (Win10 is an ISO file) are on Z:

    >> If I want to get to Z:\datastore\win10_1903\ I have to manually click in the address bar, mark the drive letter "X" and set it to "Z" and hit ENTER.

    I want to do that more easily and thought about doing it by some context menu like "goto datastore" or sth. like that. "take path" > "change X to Z" > "explorer.exe %new path%"
    Because directory names change sometimes, pinning all those folders to the taskbar would result in chaos. I already have added the Z:\datastore\ directory to my "favourites" in Explorer, but then I have to search for the correct directory (and this takes even more time than exchanging drive letters, as the time stamps sometimes are wrong so the files seem to be from the 90's).



    Nice! :)
    I already had a quick look into it and it seems to handle most of the required places in registry.

    The last thing then will be the read of the current path / directory and how to change X to Z before passing it on as a variable to explorer.exe ...

    EDIT: I should probably add Z:\ isn't always the final destination for some files. Some get moved or copied to my NAS afterwards.
    And "yes", I know this is complicated, but it's still easier than doing all the stuff manually.
     
    Last edited: Jun 9, 2019
  9. WhiteLightning

    WhiteLightning Don Illuminati Staff Member

    Messages:
    30,785
    Likes Received:
    3,959
    GPU:
    Inno3d RTX4070
    Oh i see! Have you thought about making symbolic links ? if you made one, the folder in your DL manager would not be empty as it would look in Z:\datastore\win10_1903 since its linked. https://winaero.com/blog/symbolic-link-in-windows-10/

    you could even add that to your copy script if needed.
     
    386SX likes this.
  10. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,601
    Likes Received:
    13,610
    GPU:
    GF RTX 4070
    I can write an app which will monitor specified source folder (downloads) and copy any new files to specified target folder (storage).
    I could write a requested context menu handler, but programming for Windows shell is PITA!
     
    patteSatan, BetA and 386SX like this.

  11. Watcher

    Watcher Ancient Guru

    Messages:
    2,697
    Likes Received:
    371
    GPU:
    Asus Dual RX6700 XT
    Take a look at DropIt. You may be able to work with it to perform the task you are describing.

    http://www.dropitproject.com/
     
    Last edited: Jun 10, 2019
    386SX likes this.
  12. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,601
    Likes Received:
    13,610
    GPU:
    GF RTX 4070
    But, have you actually tested the inability of HDDs to keep up with downloaded files?

    I mean , file cache sitting between the download manager and HDD should affect the whole process.
     
    Last edited: Jun 10, 2019
  13. 386SX

    386SX Ancient Guru

    Messages:
    2,084
    Likes Received:
    2,243
    GPU:
    AMD Vega64 RedDevil
    Thank you for your input guys.

    @mbk1969 : Thanks for the offer, but I want to learn how to accomplish that with Windows' own options. I only have to look into how I do the drive letter exchange.

    @Watcher : DropIt seems nice, but can't be used for this scenario. But thanks anyway. May come in handy for other stuff. :)

    @WhiteLightning : You DO have to give me the most complex stuff MS stores on its servers, don't you? (just joking) ;-)
    But OK, I will have a look into it.
     
  14. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,601
    Likes Received:
    13,610
    GPU:
    GF RTX 4070
    I can try cmd-file for the OP.
     
    386SX likes this.
  15. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,601
    Likes Received:
    13,610
    GPU:
    GF RTX 4070
    1. Locate and select 'Computer\HKEY_CLASSES_ROOT\Folder\shell' registry key.

    2. Create key 'openstorage' and modify its '(Default)' value to 'Open storage'
    [​IMG]

    3. Select newly created key 'openstorage' and create key 'command' and modify its '(Default)' value to 'X:\downloads\openstorage.cmd "%1"'.
    [​IMG]

    4. Create file 'X:\downloads\openstorage.cmd' :
    Code:
    @explorer.exe /e,/root,"Z:\storage\%~n1"
    
    That should add a context menu item "Open storage" for all folders. When you execute this context menu item in folder 'X:\downloads\name_of_download' the folder 'Z:\storage\name_of_download' will be opened in new window.
     
    BetA and 386SX like this.

  16. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,601
    Likes Received:
    13,610
    GPU:
    GF RTX 4070
    If you want a context menu item 'Copy to storage' (for a folder in downloads) which will create a folder 'name_of_download' in storage 'Z:\storage' and copy its content from downloads:
    Code:
    @echo off
    md "Z:\storage\%~n1" > nul
    xcopy "%1\*.*" "Z:\storage\%~n1" /S /Y > nul
    explorer.exe /e,/root,"Z:\storage\%~n1"
    
     
    BetA and 386SX like this.
  17. 386SX

    386SX Ancient Guru

    Messages:
    2,084
    Likes Received:
    2,243
    GPU:
    AMD Vega64 RedDevil
    @mbk1969 : As always you leave me speechless.

    Code:
    @explorer.exe /e,/root,"Z:\storage\%~n1"
    Could you please explain two things?
    1. What does this /e and /root do?
    2. What does %~n1 describe and from where does it get its data from?

    Again: Thank you very much! :)
     
  18. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,601
    Likes Received:
    13,610
    GPU:
    GF RTX 4070
    https://ss64.com/nt/explorer.html

    We use a cmd-file for the context menu handler (X:\downloads\openstorage.cmd "%1") and it receives one parameter in its command - the full path of the folder. Inside the cmd-file we can use its command line parameters with syntax "%1" (%2 for the second parameter, %3 - for the third one, etc). But if we are sure that this parameter is always a correct file path we can extract parts from the full form. For example you invoke context menu for the folder 'X:\downloads\name_of_download', then in cmd-file we can get:
    - full path in %1 => X:\downloads\name_of_download
    - drive part in %~d1 => X:
    - path part without the drive and last name (kinda parent folder) in %~p1 => \downloads\
    - last name without the drive and parent folder in %~n1 => name_of_download
    ...
    https://ss64.com/nt/syntax-args.html
     
    Last edited: Jun 10, 2019
    386SX likes this.
  19. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,601
    Likes Received:
    13,610
    GPU:
    GF RTX 4070
    Btw, if folders in downloads will have a dots in their names then both cmd-files should use '%~nx1' instead of '%~n1'.
     
    386SX likes this.
  20. 386SX

    386SX Ancient Guru

    Messages:
    2,084
    Likes Received:
    2,243
    GPU:
    AMD Vega64 RedDevil
    This! A hundred times this! You're awesome mate, really awesome. :D

    EDIT:
    Just to make sure I understood that:
    Code:
    %~d1 + %~p1 + %~n(x)1 == %1
    And %1 is the first parameter after the called *.cmd? (%2 would be the 2nd and so on ...)
    Correct?
     
    Last edited: Jun 10, 2019

Share This Page