compact-wsl2-disk icon indicating copy to clipboard operation
compact-wsl2-disk copied to clipboard

Use diskpart in script mode to circumvent problems when not running as admin

Open R0Wi opened this issue 1 year ago • 0 comments

Problem

Currently when running the script as non-admin user, the invokation of diskpart shows the Windows UAC dialog where we can input the admin user credentials for elevating the process, but piping diskpart commands to that process does not work. The diskpart commandline windows stays open and does nothing.

How to reproduce

  1. Run the script as non admin user so that is pics up all disks from that user
  2. Observe that on the diskpart line a new credentials window will pop up
  3. Provide local admin credentials, so that diskpart window can be opened
  4. Diskpart commands are not executed

Solution

Using script mode instead solves this problem.

R0Wi avatar Mar 07 '23 11:03 R0Wi