Please feel free to provide feedback or file bugs here.

[BUG] Drag and drop to scripts shortcuts split paths containing spaces

Drag and dropping any file to a script shortcut split this path before passing the splitted strings as multiple parameters. Here's my detailed Issue Report :

Steps to reproduce
------------------

1 - Get any script, for example :
[samplescript.psd1] :
```
param([string]$path)
Write-Host($path)
pause
```
or a simpler one-line sample: ```Write-Host($args);pause```

2 - Create a shortcut that runs the script :
[Shortcut Target ] : ```PowerShell "path\to\our\samplescript.psd1"```

3- Drag and drop a file containing spaces in its name to the shortcut
[sample file ] : ```C:\Some file with spaces.txt```

Expected behavior
-----------------

Drag and dropping the file should pass its path to the script as a parameter, (as it does correctly with batch scripts, executables, and other files that accept drag and drop [and shortcuts to these]),
and the script should then open a PowerShell window displaying "C:\Some file with spaces.txt"

Actual behavior
---------------

The file path is split into multiple parameters before being passed to the PowerShell script, which displays "C:\Some", instead of "C:\Some file with spaces.txt"

Workaround
---------------

Well, that isn't brilliant since I'm since starting to have a lot of these, but since this bug is only with powershell I simply create a .bat file which passes the argument to a PowerShell file. Instead of drag and dropping to the script shortcut; I drop it on the bat file [or a shortcut to it] to pass the path to the bat file, which then pass the path to the PowerShell script. Like this :
[dragdrop_for_samplescript.bat]
```start PowerShell -file "path\to\our\samplescript.psd1" %1```

Environment data
----------------

```
> $PSVersionTable

Name Value
---- -----
PSVersion 5.1.16257.1
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.16257.1
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
```

2 votes
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)

    We’ll send you updates on this idea

    Amine I. shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    1 comment

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Amine I. commented  ·   ·  Flag as inappropriate

        UPDATE : The bug seems to only affects the scripts with a Param( ) block :
        the one-line-script provided (Write-Host($args);pause) is in fact not affected

      Feedback and Knowledge Base