compact-wsl2-disk
compact-wsl2-disk copied to clipboard
Use diskpart in script mode to circumvent problems when not running as admin
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
- Run the script as non admin user so that is pics up all disks from that user
- Observe that on the
diskpart
line a new credentials window will pop up - Provide local admin credentials, so that
diskpart
window can be opened - Diskpart commands are not executed
Solution
Using script mode instead solves this problem.