title: Batch %~f1 works but %~dp1 fails because of spaces
body: <p>I am trying to create a batch script to send a shortcut of a file to my start menu but I have ran into trouble setting the "Start in" option. I am using <a href="http://www.optimumx.com/downloads.html#Shortcut" rel="nofollow noreferrer">Shortcut from Optimum X</a> to do it and this may be an error from their decade old program and not my code.</p>
  
  <ul>
  <li><code>%~f1</code> = <code>C:\Program Files (x86)\Example\Example.exe</code></li>
  <li><code>%~dp1</code> = <code>C:\Program Files (x86)\Example\</code></li>
  </ul>
  
  <p>Running </p>
  
  <pre><code>shortcut /f:"%targetfolder%\%fileName%.lnk" /w:"%~f1" /a:c /t:%1
  </code></pre>
  
  <p>works as intended and creates a shortcut with the "Start in" set to the dir of the file. But running</p>
  
  <pre><code>shortcut /f:"%targetfolder%\%fileName%.lnk" /w:"%~dp1" /a:c /t:%1
  </code></pre>
  
  <p>fails when it encounters a space, for example if the path is in Program Files the error is </p>
  
  <p>"The Parameter "Files" is invalid</p>
  
  <p>The Syntax of the command is incorrect"</p>
  
  <p><a href="https://i.imgur.com/MDphXrh.png" rel="nofollow noreferrer"><img src="https://i.imgur.com/MDphXrh.png" alt="The Error."></a></p>
  
  <p>Sorry if this is not enough information I know very little Batch.</p>