scheduling defrag for those that don't want to leave machines on overnight.
I've been looking around the web, and trawling through CMD.exe for a good few hours now, and I still can't find it.
I'm trying to create a batch file that defrags a machines c: drive, and then shuts down the computer as soon as it's finished, having given a 2 minute warning. That was the easy bit.
I'm now struggling to find out how to get a simple (Y/N) input from a user as the script starts asking whether the user wants to defrag and shutdown or not waiting 60 seconds for an answer before procedding to defrag and shutdown the computer if no answer is given.
The idea is to schedule it to run at 2am every day, probably from Task Scheduler. It's an experiment in learning as much as anything else though, but I am now completely stuck, bogged down in pages and pages of useless information while trying to find the piece I want.
If anybody knows how to do it, I'd appreciate your help.
I've been looking around the web, and trawling through CMD.exe for a good few hours now, and I still can't find it.
I'm trying to create a batch file that defrags a machines c: drive, and then shuts down the computer as soon as it's finished, having given a 2 minute warning. That was the easy bit.
@echo off
defrag c:
C:\WINDOWS\SYSTEM32\TSSHUTDN.EXE 0 /DELAY:120 /POWERDOWN
I'm now struggling to find out how to get a simple (Y/N) input from a user as the script starts asking whether the user wants to defrag and shutdown or not waiting 60 seconds for an answer before procedding to defrag and shutdown the computer if no answer is given.
The idea is to schedule it to run at 2am every day, probably from Task Scheduler. It's an experiment in learning as much as anything else though, but I am now completely stuck, bogged down in pages and pages of useless information while trying to find the piece I want.
If anybody knows how to do it, I'd appreciate your help.