microsoft / sudo

It's sudo, for Windows

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please support `-D`/`--chdir`

joshtriplett opened this issue · comments

sudo for Linux supports a -D/--chdir option, which changes to a specified directory before running the specified command. Please consider supporting the same option.

Totally seems reasonable to me. I think this was in the spec originally, just slipped my mind 😅

Something we'll have to keep in mind:

image

-D combined with --newWindow mode will need to do the same thing we do for -E, where we launch sudo elevated instead of the target app.

-D combined with --newWindow mode will need to do the same thing we do for -E, where we launch sudo elevated instead of the target app.

Wait! This is a problem @zadjii-msft and should be tracked as its own bug !

People may use newWindow as a config setting and forget about it... then and occasionally do sudo notepad.exe ./somefile.txt or even worse sudo del ./*.* expecting to affect the current directory, but hit System32!

So you may no longer want to do Start-Process -verb RunAs on the target command, because you can't specify a start folder on that Api. You can launch sudo elevated or modify the Windows Api... Have you considered modifying the Windows Api?

You know what, we actually did merge this in MSFT:48995647 (internally).