Showing results for 
Show  only  | Search instead for 
Did you mean: 

Schedule Reboot using AT and psshutdown with time input

Champion Sweeper II
Hello - I have a custom computer action that schedules a reboot for 2am the following morning. It looks lke this:
cmd.exe /C psexec \\{computer} at 2:00am psshutdown -r -f -c -t 10 /accepteula

This works fine (see below), but I would like to be able to have LS ask me what time to schedule the reboot. I'm sure this would require a script. I can write a script that asks for data (InputBox?), but I don't know how to write a script that would then insert this information as a parameter for the AT command. Do any of you master script writers know how to do this?


See post #7 where, with the assistance of other posters, I was able to come up with a valid way to do this.
See also post #14 where danielm greatly improved upon this, expanding it to include other options for CHKDSK and handling scheduled tasks.

Engaged Sweeper
How do I get this to work as a new lansweeper customer? I do not understand what you guys mean by AT.

Engaged Sweeper III
This works wonderfully!!! Thanks!

Champion Sweeper III
Awesome, thanks!

Lansweeper Employee
Lansweeper Employee
It's not an action, but you could use the deployment feature to get what you want.
Ex. Deploy a script that creates a schedule, deploy a command,...
If it ain't broke, don't fix it.

Champion Sweeper III
I know I am replying to an old thread but I am hoping someone is still subscribed to it.

How do you add something so that it's scheduled? Add a custom action that runs on a schedule?

Champion Sweeper II
Glad it can help someone.
I kept it all in one batch file to have one simple all inclusive click command:)

Champion Sweeper II
Thanks danielm, I love it! You have several commands in there that I'm not familiar with regarding syntax, etc. so I'm glad you put that together.

It makes sense that you may want to do a CHKDSK when rebooting.

I edited it slightly just for readability. I also saved it again as SchedShutdown.bat for shutdown. For that one I removed the CHKDSK section and edited the shutdown command, of course.

Thanks again!


Champion Sweeper II
I've just expanded this Idea to have it
show current time and schedule on remote pc
ask to DELETE schedule
ask to delete again 🙂
and then ask to add a time for it to reboot. allowing for ENTER to skip.

I went the way of AT \\pcname instead of psexec.

ok..a bit messy but here's the idea...

**just added CHKDSK scheduling and removal 🙂

{actionpath}SchedReboot.bat {computer}

@echo off
if %1.==. GOTO END

set /p chkdsk1=Schedule C Chkdsk? [1= /F 2= /R 3=StopCheck enter=skip]
if {%chkdsk1%}=={1} psexec -d \\%1 -s cmd /c "echo y|chkdsk c: /f"
if {%chkdsk1%}=={2} psexec -d \\%1 -s cmd /c "echo y|chkdsk c: /f /r"
if {%chkdsk1%}=={3} psexec -d \\%1 -s chkntfs c: /x

ECHO Current AT Schedule is
at \\%1
REM Clearing variables
set chkdsk1=
set delsched=
set idnum=
set delagain=
set sdtime=
set /p delsched=Do you wish to delete a schedule (n/y) [enter=skip]?
if {%delsched%}=={y} goto yesdel
if {%delsched%}=={n} goto nodel
if %delsched%.==. goto nodel
goto nodel
set /p idnum=Enter number only of ID to delete [# or SPACE for All]?
at \\%1 %idnum% /delete

set /p delagain=Do you wish to delete another (n/y) [enter=skip]?
if {%delagain%}=={y} goto STARTOFDELETE
if {%delagain%}=={n} goto noagaindel


set /p sdtime=Time on Target Computers Local Time (2:00am , 02:00) [enter=skip]?
if %sdtime%.==. GOTO BLANK


ECHO Time entered: %sdtime%
at \\%1 %sdtime% shutdown -r -t 60 -f
Echo Reboot setup at time select with 60 second delay.
ECHO Press any key to close this window...



Engaged Sweeper III
at \\%1 %sdtime% shutdown -r -t 00 -f

works fine for me, and does it on the right machine (CHQAUDT078 in this example)

What time? 14:00

Time entered: 14:00
Added a new job with job ID = 3

Current box
Status ID Day Time Command Line
1 Each M 3:00 AM "D:\Update Dell\UpdateDellWarrantyInfo.exe"

Status ID Day Time Command Line
3 Tomorrow 2:00 PM shutdown -r -t 00 -f
Press any key to close this window...