DigitalNam
asked on
Help restarting Windows XP everyday at a certain time.
Well my title sums up my question. I need to restart Windows XP everyday at a certain time. Do I need to use a timer to check the time?
Thanks
Thanks
Fairly simple, you need write a script that uses the SHUTDOWN command, then fire it with task scheduler. Type "shutdown" at a command prompt for a template, go to "Control panel", "Sheduled tasks" to add a task.
ASKER
Any other solution malmensa? I do not want to use the windows task scheduler.
You just need a scheduled task to perform a reboot, it's prebuilt into windows.
It should have existing schedules for scandisk/ddefrag etc, look at them and create one for a shutdown/reboot
It should have existing schedules for scandisk/ddefrag etc, look at them and create one for a shutdown/reboot
Create a schedule task that runs %SystemRoot%\System32\shut down.exe -r -t 00
this will restart immediately at the time you set in the schedule.
use -s to shutdown instead of restart
change 00 to how many seconds to wait before restart
this will restart immediately at the time you set in the schedule.
use -s to shutdown instead of restart
change 00 to how many seconds to wait before restart
Hmm, why don't you want to use windows task scheduler?
It's free and already installed - that's its purpose to perform scheduled operations - it sits in the taskbar and waits to run tasks.
Unless you want to write something yourself in Visual Basic that isn't obvious to a user and unknown to them reboots the PC - but applications like that may not work given antivirus software etc; best to use the approved Microsoft Program so you know for certain it iwll work.
It's free and already installed - that's its purpose to perform scheduled operations - it sits in the taskbar and waits to run tasks.
Unless you want to write something yourself in Visual Basic that isn't obvious to a user and unknown to them reboots the PC - but applications like that may not work given antivirus software etc; best to use the approved Microsoft Program so you know for certain it iwll work.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
ThievingSix: this looks like what I am looking for. Don't have time to test it now,but will test it within the next few hours and award points. Thanks.
The only thing I can say about the code is when setting the ShutdownTime constant, use the format: "00:00:00 am". No more characters, no less.
Also you might want to change the final Sleep(1000) to Sleep(500) or Sleep(750) because there is a slight chance that it will miss your time by a second if you don't.
Also you might want to change the final Sleep(1000) to Sleep(500) or Sleep(750) because there is a slight chance that it will miss your time by a second if you don't.
ThievingSix -->
1) Start a new application.
2) Remove Unit1(Project Menu --> Remove From Project).
3) View project source(Project Menu --> View Source).
this looks like the Create Console Application button
1) Start a new application.
2) Remove Unit1(Project Menu --> Remove From Project).
3) View project source(Project Menu --> View Source).
this looks like the Create Console Application button
No. This isn't a console app. It would have to say {$APPTYPE Console} for that.
yeah, the only line would then be :
delete {$APPTYPE Console} line :)
delete {$APPTYPE Console} line :)
and off course
uses windows, sysutils;
uses windows, sysutils;
True, same thing in the end.
ASKER
Sorry for not responding for a while but one of the perks of living in a small town in Namibia is the lack of a reliable internet connection :-)
Thieving: This may sound stupid but how do I integrate your solution into an already existing project? I copied and pasted it in my current project but with the function, all code after it is ignored. Maybe I am overlooking something or just being stupid...
Thieving: This may sound stupid but how do I integrate your solution into an already existing project? I copied and pasted it in my current project but with the function, all code after it is ignored. Maybe I am overlooking something or just being stupid...
ASKER
thank you for the help. sorry it took so long to award the points.
Put this in a timer
CurrentTime := FormatDateTime('hh:nn:ss am/pm',Now);
If (CurrentTime = ShutdownTime) Then
begin
While Not RestartWindows Do
begin
Sleep(1000);
end;
end;
Sleep(1000);