If you want to defrag a drive with a command, you can use a command to do the same. So, open the Command Prompt as an administrator either from the Start Menu or by Run(Win + R), type "cmd", and hit Ctrl + Shift + Enter.
Type the following command and hit Enter.
defrag C:
You can replace 'C' with the drive letter you want to defrag.