You're all overcomplicating this...
Use the Windows "AT" command to set up a scheduled task. This task launches a simple batch file, that runs a simple VBScript that launches the Windows disk defragmenter.
All simple... all free.... and all runs under local system privileges... no domain user accounts involved.
Contents of the batch file> C:\defrag.vbs
(this assumes that the location of your VBScript will be on the root of C, but the VBScript can be stored anywhere)
Contents of the VBScript file (in this case we're calling it defrag.vbs) >
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colVolumes = objWMIService.ExecQuery _
("Select * from Win32_Volume Where Name = 'C:\\'")
For Each objVolume in colVolumes
errResult = objVolume.Defrag()
Next
......if you have multiple drives, C, D and E etc. you'll need to set up a scheduled task and script for each. You can create the batch file and the VBScript file in notepad. For the VBScript file, save the notepad file with a .vbs extension instead of the normal .txt and for the batch file, save the file with a .bat extension.
For info. on the AT command >