windows - Remove Trailing \ in subst Command -


i have added command context menu via registry in hkcr\drive\shell\maplocaldrivehere\command such when right click drive. i'd give me name of drive have right-clicked "c:" not "c:\", causes problems command i'm trying run.

cmd /c subst %1 /d 

this expands to:

cmd /c subst c:\ /d 

and command fails (it expects subst c: /d). how parameter without trailing \, or remove it? %~d1 , %~1 don't expand registry key, type reg_expand_sz.

you can understand better i'm trying viewing source of project, located @ https://github.com/ehryk/contextmenutools (especially file: https://github.com/ehryk/contextmenutools/blob/master/custom%20installs/map%20local%20drive%20here/maplocaldrivehere.inf )

you in for /f loop %%~d parameter drive letter colon:

for /f "delims=" %%a in ("%~1") cmd /c subst %%~da /d 

Comments