
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2012 11:40 PM - last edited on ‎04-01-2024 04:38 PM by Mercedes_O
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.
- Labels:
-
API & Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2012 08:12 PM
Just wondering why you are using PSEXEC and not just AT since you can pass the computer name on it and it does the same thing.
Just wondering.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2012 06:30 PM
dteague wrote:
Just wondering why you are using PSEXEC and not just AT since you can pass the computer name on it and it does the same thing.
Hi dteague,
If I use "AT %sdtime% \\%1 shutdown..." in the batch file it schedules this task on my computer:
"\\computer shutdown..."This would require my computer to be on the network and turned on at the scheduled time. In most cases, the target computer is a server that I'd want to reboot in the middle of the night. My computer would be with me at home and shutdown at that time.
If I use "psexec \\%1 AT %sdtime% shutdown..." it schedules this task on the target computer:
"AT {time} shutdown..."This is the desired result.
I hope that helps.
Jono

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2012 09:59 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2012 11:34 PM
dteague wrote:
I see what it is, you were putting the time in the wrong place. It has to be after the server name for it to schedule it on that machine. I am supprised that it scheduled it on your machine, and not just errored and given you the AT help dump.
Good call dteague; my mistake. I suppose it works either way, though yours is a bit simpler.
Thanks,
Jono

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2012 04:57 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2012 07:50 PM
This is the action in LS config
{actionpath}SchedReboot.bat {computer}
This is the SchedReboot.bat file
@echo off
ECHO.
set /p sdtime=What time?
ECHO.
ECHO Time entered: %sdtime%
psexec \\%1 at %sdtime% shutdown -r -f
ECHO.
ECHO Press any key to close this window...
pause>nul
This asks for a time to assign to the sdtime variable, echos back what it now sees as the sdtime variable, and then uses psexec and builds the AT command with the sdtime variable on the chosen computer.
I created another one (named SchedShutdown.bat) that's identical except for the "-r" in the shutdown command is "-s" for shutdown instead of reboot.
I just tested it and it works great. I hope others might find this useful. I suppose this same idea could be used to schedule any command to run at a certain time.
Thanks again for your help, ejensen.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2012 06:10 PM
I ran across this and figured it would help you come up with a solution. If you have problems doing this just let me know and I will help build something for you.
http://www.robvanderwoude.com/userinput.php

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2012 04:50 PM
My custom action for a scheduled reboot now looks like this:
cmd.exe /K psexec \\{computer} at 2:00am shutdown -r -f
I also have a custom action to schedule a shutdown which is the same as the reboot, only replacing the -r for reboot with -s for shutdown.
I still haven't been able to find the time to work on the 2-batch-files solution to having LS ask me for a time. Once I have that done, I'll post it here for anyone who may be interested in the same thing.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2012 05:45 PM
there is a command line switch to specify the time of the shutdown or reboot:
-t Specifies countdown in seconds until shutdown (default is 20) or
the time of shutdown (in 24 hour notation)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2012 05:59 PM
ejensen wrote:
Actually Jono, after thinking about it a few minutes... just use the psshutdown utility form sysinternals (same guys that make psexec).
there is a command line switch to specify the time of the shutdown or reboot:-t Specifies countdown in seconds until shutdown (default is 20) or
the time of shutdown (in 24 hour notation)
Hi ejensen - Thanks for the reply. I'm actually already using psshutdown and I could specify the time there rather than the AT command, but I want to be able to choose a time for the reboot each time I execute the command.
I'd like to be able to click the custom action, enter a time, and have that time be entered into the -t argument in the command. This would be a lot easier than having to edit the command in LS Config each time.
I'll spend some time today working on the dual batch file option you mentioned earlier.
By the way, in my original post, I spoke too soon. The scheduled task actually doesn't work, but I'm not sure why. It runs if I run it at a cmd prompt, but not when it's scheduled. This morning I reset the command to use the -t argument to schedule the time rather than the AT command.
I'll post results here.
