GChuf / RCWM

Right Click Windows Magic is an open-source set of right-click (context) menu tools for admins, power users and other magic beings. Batch&Powershell.
GNU General Public License v3.0
102 stars 9 forks source link

Get the list of files and folders that were copied from a .NET Framework #22

Open raziel6868 opened 1 year ago

raziel6868 commented 1 year ago

Is your feature request related to a problem? Please describe. After reviewing the source code of rcp.ps1, I suppose the script stores a list of folders in the registry key HKCU:\RCWM and then for each folder, the script uses robocopy to copy or move it to the specified destination. However, with thousands of folders and large files to copy, the amount of registry value generated in HKCU:\RCWM will be enormous, negatively impacting read/write speed of Windows Registry.

Describe the solution you'd like I'm thinking of using System.Windows.Forms.Clipboard to get list of folders and files from users pressing Ctrl+C or click Copy on right click menu, after that you can use Robocopy loop to go through the list. What do you think ?

Add-Type -AssemblyName System.Windows.Forms
$selectedItems = [System.Windows.Forms.Clipboard]::GetFileDropList()

foreach ($item in $selectedItems) { something ... }

Additional context

GChuf commented 1 year ago

@minlmao thank you for your recommendation! That's right, the script stores folder paths into registry, however not every subfolder and file is stored into the registry, and the list gets cleaned after robocopy finishes - so the registry doesn't get bloated.

However, the idea is great. I've given it some thought and I think I could implement it together with the existing system. Right now, I'm not sure if I can save the folder names to clipboard if the user is copying multiple folders through the right click menu. If there's an option to append folders to the clipboard, then it might be possible, because the script currently opens a new process for every folder selected. All of this would be solved if I had a proper context menu handler written in c++, for example.

For copying single folders, and for using ctrl+C, there should be no major problems.