'Shutdown at start only once (after chkdsk) with batch
I'm making a batch script for general windows pc maintenance (to delete file temp, defrag, chkdsk etc) that will be run on several pcs (mostly win7 and some win10). In the end, my script set a chkdsk on the next reboot and reboot the machine.
Now I need that, when the chkdsk ends and the machine reboots, that the PC turns off automatically. The only vanilla solution that I could think about was to set a scheduled task with 2 actions: one for the shutdown (shutdown /s /f /t 20) and another one to delete the task for avoiding the loop. The task must be executed at Windows startup (no user has to log in) and that's the problem because while the shut down from prompt doesn't require a logged user, it appears that the task deletetion needs it (setting it with PowerShell). I tried to delete the task through "reg delete", but still, it doesn't work (I think for the same reason).
Can anyone help? How to set a task like a shutdown Once but on Start?
P.s. I can't set the task with a clear admin password to get admin rights for security reasons Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
