ildar-shaimordanov / psubst

Associates a path with a drive letter and extends the standard SUBST command allowing to create persistent substituted drives between startups
MIT License
170 stars 40 forks source link

/PF gives "Invalid parameter" error #21

Open JoanEliot opened 3 years ago

JoanEliot commented 3 years ago

Originally I thought there was a problem with /PF because I got an error when using the parameter in the wrong place.

This is incorrect: psubst /PF K: C:\z\K (but psubst /P K: C:\z\K did not throw an error)


Now I have an error when using /PF in the right place: C:\util>psubst K: C:\z\K /PF psubst: Unable to add persistently SUBSTed drive

However, pubst /P reports the drive as present, despite the error. Does that mean I have a SUBSTed drive with the features of a /P persistence, but not those expected with /PF?

C:\util>psubst /P
K:\: => C:\z\K
ildar-shaimordanov commented 3 years ago

That's correct because the order of the arguments and options is mandatory. Run the tool with /? option and to learn more about usage. The correct usage is as follows:

PSUBST [drive1: [drive2:]path] [/P | /PF]
JoanEliot commented 3 years ago

Sorry! I missed your reply before I edited my original post. I figured out I had the argument in the wrong place, and then ran into a new issue as above. But as for the order of arguments point, I get no error message with pubst /P so maybe an update to recognize that also as an out-of-order parameter?

ildar-shaimordanov commented 3 years ago

The command psubst /P K: C:\z\K doesn't throw any issues because it's executed as this one psubst /P (ignoring everything after /p).

Regarding the second issue Unable to add persistently SUBSTed drive. I reviewed the code and didn't find any reasons to throw it with the /pf option. This could happen with the /p option only (and without elevated privileges).

Can you remove the entry with the command psubst K: /d /pf, then repeat the creation command psubst K: C:\z\K /PF? Let me know more details.

JoanEliot commented 3 years ago

Results (non-elevated or elevated, same):

>psubst K: /d /pf
psubst: Drive not SUBSTed persistently
>k:
K:\>
>psubst K: C:\z\K /PF
psubst: Unable to add persistently SUBSTed drive

But regardless, the 'K drive' is working and giving me no trouble—I don't seem to need whatever /PF offers.

ildar-shaimordanov commented 3 years ago

I need to understand or become closer in understanding what's wrong in your situation. Would you be perform the following steps:

  1. Run these commands first time before starting to modify old entries:
    reg export "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices" tempfile
    type tempfile
  2. open RegEdit application and proceed the path HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices; find the K: value and delete it
  3. Run psubst /p
  4. Run psubst K: C:\z\K /PF
  5. Run psubst /p again

Share results here.

JoanEliot commented 3 years ago

Sorry for not replying earlier. Still pretty busy so can't promise prompt feedback but here you go—

Results (tempfile listing -- note that there is no entry for K )

"AUX"="\\DosDevices\\COM1"
"CON"="\\Device\\ConDrv\\Console"
"CONIN$"="\\Device\\ConDrv\\CurrentIn"
"CONOUT$"="\\Device\\ConDrv\\CurrentOut"
"MAILSLOT"="\\Device\\MailSlot"
"NUL"="\\Device\\Null"
"PIPE"="\\Device\\NamedPipe"
"PRN"="\\DosDevices\\LPT1"
"Silos"="\\Silos"
"UNC"="\\Device\\Mup"

>psubst K: C:\z\K /PF
psubst: Unable to add persistently SUBSTed drive
ildar-shaimordanov commented 3 years ago

@JoanEliot, I guess, the user you work with doesn't have writing permissions in the particular subkey. Let's try one more attempt.

  1. Download the file sudo.bat from this link: https://raw.githubusercontent.com/ildar-shaimordanov/cmd.scripts/master/unix-like/sudo.bat. Save it next to psubst.bat
  2. Run it. It will open a new console window (titled as "Administrator")
  3. In this new window run the command psubst K: C:\z\K /p
  4. Check the list of SUBSTed drives with psubst /p
  5. Show the Windows version running the command ver

Capture the results of all commands you execute in this attempt and share.