Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save yanegorz/c93331dc8efa8b6d5c90e37ade450efd to your computer and use it in GitHub Desktop.

Select an option

Save yanegorz/c93331dc8efa8b6d5c90e37ade450efd to your computer and use it in GitHub Desktop.

Revisions

  1. @ipcjs ipcjs revised this gist Sep 23, 2020. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions +Windows 10 Add Copy-Paste as Symbolic Link or Junction.md
    Original file line number Diff line number Diff line change
    @@ -1 +1,5 @@
    # Windows 10 Add Copy-Paste as Symbolic Link or Junction

    English: Add a menu item of `Paste Symlink` to the Windows right-click menu

    中文:给Windows的右键菜单添加`粘贴成符号链接`的菜单项
  2. @ipcjs ipcjs revised this gist Sep 23, 2020. 2 changed files with 2 additions and 1 deletion.
    1 change: 1 addition & 0 deletions +Windows 10 Add Copy-Paste as Symbolic Link or Junction.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    # Windows 10 Add Copy-Paste as Symbolic Link or Junction
    2 changes: 1 addition & 1 deletion paste-symlink.reg
    Original file line number Diff line number Diff line change
    @@ -4,5 +4,5 @@ Windows Registry Editor Version 5.00
    @="Paste Symlink"

    [HKEY_CLASSES_ROOT\Directory\Background\shell\1_PasteSymlink\command]
    @="powershell.exe -File \"D:\\GitHub\\gist\\82e4385532be90eac99546df99a2854d\\paste-symlink.ps1\" -location \"%V\""
    @="powershell.exe -File \"C:\\GitHub\\gist\\82e4385532be90eac99546df99a2854d\\paste-symlink.ps1\" -location \"%V\""

  3. @ipcjs ipcjs revised this gist Aug 8, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions paste-symlink.reg
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\Directory\Background\shell\a_PasteSymlink]
    [HKEY_CLASSES_ROOT\Directory\Background\shell\1_PasteSymlink]
    @="Paste Symlink"

    [HKEY_CLASSES_ROOT\Directory\Background\shell\a_PasteSymlink\command]
    [HKEY_CLASSES_ROOT\Directory\Background\shell\1_PasteSymlink\command]
    @="powershell.exe -File \"D:\\GitHub\\gist\\82e4385532be90eac99546df99a2854d\\paste-symlink.ps1\" -location \"%V\""

  4. @ipcjs ipcjs revised this gist Jul 3, 2019. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion paste-symlink.ps1
    Original file line number Diff line number Diff line change
    @@ -22,12 +22,18 @@ else {
    else {
    # When enable develper mode, New-Item require admin on some computer, but mklink no require... why?!!
    # New-Item -ItemType SymbolicLink -Name $file.name -Target $file
    if ($file.Attributes -eq 'Directory') {

    # `file.Attributes` to check path is a directory is invalid on some computer...replace to `Test-Path`.
    # if ($file.Attributes -eq 'Directory') {
    if ((Test-Path $file -PathType Container) -eq $true) {
    # Write-Output "dir"
    cmd /c mklink /d $file.name $file
    }
    else {
    # Write-Output "file"
    cmd /c mklink $file.name $file
    }
    # Pause
    }
    }
    }
  5. @ipcjs ipcjs revised this gist Jun 10, 2019. 1 changed file with 10 additions and 3 deletions.
    13 changes: 10 additions & 3 deletions paste-symlink.ps1
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # Add windows Explorer Right-Click menu to paste copied item as Junction or SymbolicLink with PowerShell
    # Locate file on C:\CMD\
    # Add windows Explorer Right-Click menu to paste copied item as SymbolicLink with PowerShell
    # Locate file on D:\GitHub\gist\82e4385532be90eac99546df99a2854d\

    param (
    [Parameter(Mandatory = $true)][string]$location
    @@ -20,7 +20,14 @@ else {
    Pause
    }
    else {
    New-Item -ItemType SymbolicLink -Name $file.name -Target $file
    # When enable develper mode, New-Item require admin on some computer, but mklink no require... why?!!
    # New-Item -ItemType SymbolicLink -Name $file.name -Target $file
    if ($file.Attributes -eq 'Directory') {
    cmd /c mklink /d $file.name $file
    }
    else {
    cmd /c mklink $file.name $file
    }
    }
    }
    }
  6. @ipcjs ipcjs revised this gist Jun 10, 2019. 2 changed files with 19 additions and 28 deletions.
    41 changes: 16 additions & 25 deletions paste-symlink.ps1
    Original file line number Diff line number Diff line change
    @@ -1,35 +1,26 @@
    # Add windows Explorer Right-Click menu to paste copied item as Junction or SymbolicLink with PowerShell
    # Locate file on C:\CMD\
    param (
    [Parameter(Mandatory=$true)][string]$location
    )

    param (
    [Parameter(Mandatory = $true)][string]$location
    )

    Set-Location $location
    $files = Get-Clipboard -Format FileDropList
    $count = $files.count;
    if($count -eq 0)
    {
    echo "No file(s) in clipboard"
    pause
    exit
    if ($count -eq 0) {
    Write-Output "No file(s) in clipboard"
    Pause
    }
    echo "Making Junction/Link of $count files"
    foreach ($file in $files)
    {
    if( (Test-Path $file.Name) -eq $true ){
    echo "$($file.Name) Exists"
    }else{
    if($file.Attributes -eq 'Directory')
    {
    #echo "Junction: $($file.Name) -> $file"
    New-Item -ItemType Junction -Name $file.name -Target $file
    } else
    {
    #echo "SymLink : $($file.Name) -> $file"
    else {
    Write-Output "Making Junction/Link of $count files"
    foreach ($file in $files) {
    if ( (Test-Path $file.Name) -eq $true ) {
    Write-Output "$($file.Name) Exists"
    Pause
    }
    else {
    New-Item -ItemType SymbolicLink -Name $file.name -Target $file
    }

    }

    }
    pause
    }
    6 changes: 3 additions & 3 deletions paste-symlink.reg
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\Directory\Background\shell\runas]
    [HKEY_CLASSES_ROOT\Directory\Background\shell\a_PasteSymlink]
    @="Paste Symlink"

    [HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command]
    @="powershell.exe -File \"C:\\CMD\\paste-symlink.ps1\" -location \"%V\""
    [HKEY_CLASSES_ROOT\Directory\Background\shell\a_PasteSymlink\command]
    @="powershell.exe -File \"D:\\GitHub\\gist\\82e4385532be90eac99546df99a2854d\\paste-symlink.ps1\" -location \"%V\""

  7. @ndunks ndunks created this gist Sep 30, 2017.
    35 changes: 35 additions & 0 deletions paste-symlink.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    # Add windows Explorer Right-Click menu to paste copied item as Junction or SymbolicLink with PowerShell
    # Locate file on C:\CMD\
    param (
    [Parameter(Mandatory=$true)][string]$location
    )

    Set-Location $location
    $files = Get-Clipboard -Format FileDropList
    $count = $files.count;
    if($count -eq 0)
    {
    echo "No file(s) in clipboard"
    pause
    exit
    }
    echo "Making Junction/Link of $count files"
    foreach ($file in $files)
    {
    if( (Test-Path $file.Name) -eq $true ){
    echo "$($file.Name) Exists"
    }else{
    if($file.Attributes -eq 'Directory')
    {
    #echo "Junction: $($file.Name) -> $file"
    New-Item -ItemType Junction -Name $file.name -Target $file
    } else
    {
    #echo "SymLink : $($file.Name) -> $file"
    New-Item -ItemType SymbolicLink -Name $file.name -Target $file
    }

    }

    }
    pause
    8 changes: 8 additions & 0 deletions paste-symlink.reg
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\Directory\Background\shell\runas]
    @="Paste Symlink"

    [HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command]
    @="powershell.exe -File \"C:\\CMD\\paste-symlink.ps1\" -location \"%V\""