cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Jono
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?

Thanks,
Jono

Solutions:
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.

20 REPLIES 20
spatche
Engaged Sweeper
How do I get this to work as a new lansweeper customer? I do not understand what you guys mean by AT.
IFIT
Engaged Sweeper III
This works wonderfully!!! Thanks!
sullivane
Champion Sweeper III
Awesome, thanks!
Bert_D
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,...
sullivane
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?
danielm
Champion Sweeper II
Glad it can help someone.
I kept it all in one batch file to have one simple all inclusive click command:)
Jono
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!

Jono
danielm
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


:CHKDSK1
ECHO.
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

:STARTOFDELETE
ECHO.
NET TIME \\%1
ECHO Current AT Schedule is
at \\%1
REM Clearing variables
set chkdsk1=
set delsched=
set idnum=
set delagain=
set sdtime=
ECHO.
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
:yesdel
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
:noagaindel

:nodel

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

ECHO.

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

GOTO END

:BLANK
:END

dteague
Engaged Sweeper III
Odd...
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"

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

New to Lansweeper?

Try Lansweeper For Free

Experience Lansweeper with your own data.
Sign up now for a 14-day free trial.

Try Now