How to launch Windows Scheduler by command-line? [closed] - windows

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I mean to open the built-in Windows GUI from command line- not to launch by Schtasks

taskschd.msc is available in Windows Vista and later.
http://technet.microsoft.com/en-us/library/cc721871.aspx
I could have sworn I'd seen a little task scheduler GUI like you're talking about prior to Vista, but maybe I was thinking of the "Add Scheduled Task" wizard.
You might have to settle for opening the scheduled tasks explorer with this command:
control schedtasks
I couldn't find any way to launch the "Add Scheduled Task" wizard from the command line, unfortunately (there has to be a way!)

I'm using Windows 2003 on the server. I'm in action with "SCHTASKS.EXE"
SCHTASKS /parameter [arguments]
Description:
Enables an administrator to create, delete, query, change, run and
end scheduled tasks on a local or remote system. Replaces AT.exe.
Parameter List:
/Create Creates a new scheduled task.
/Delete Deletes the scheduled task(s).
/Query Displays all scheduled tasks.
/Change Changes the properties of scheduled task.
/Run Runs the scheduled task immediately.
/End Stops the currently running scheduled task.
/? Displays this help message.
Examples:
SCHTASKS
SCHTASKS /?
SCHTASKS /Run /?
SCHTASKS /End /?
SCHTASKS /Create /?
SCHTASKS /Delete /?
SCHTASKS /Query /?
SCHTASKS /Change /?
┌─────────────────────────────────────┐
│ Executed Wed 02/29/2012 10:48:36.65 │
└─────────────────────────────────────┘
It's quite interesting and makes me feel so powerful. :)

This launches the Scheduled Tasks MMC Control Panel:
%SystemRoot%\system32\taskschd.msc /s
Older versions of windows had a splash screen for the MMC control panel and the /s switch would supress it. It's not needed but doesn't hurt either.

Yes, the GUI is available in XP. I can get the list of scheduled tasks (but not the GUI) to open with the following command,
control.exe schedtasks
Then you can use the wizard to add a new scheduled task, for example.
In XP, you can find the Scheduler GUI from within Windows Help if you search for "Scheduled Tasks" then click on "Step by Step instructions" and open the scheduler GUI. Clicking on the last link executes the following command, which likely could be translatedinto something that would open the Scheduler GUI from the command line. Does anyone know how?
ms-its:C:\WINDOWS\Help\mstask.chm::/EXEC=,control.exe, schedtasks CHM=ntshared.chm FILE=alt_url_windows_component.htm

Here is an example I just used:
at 8am /EVERY:M,T,W,Th,F,S,Su cmd /c c:\myapp.exe
The result was:
Added a new job with job ID = 1
Then, to check my work:
at

You might want to have look at simple command line scheduler "at":
C:\Documents and Settings\mahendra.patil>at/?
The AT command schedules commands and programs to run on a computer at
a specified time and date. The Schedule service must be running to use
the AT command.
AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
AT [\\computername] time [/INTERACTIVE]
[ /EVERY:date[,...] | /NEXT:date[,...]] "command"
\computername Specifies a remote computer. Commands are scheduled on the
local computer if this parameter is omitted.
id Is an identification number assigned to a scheduled
command.
/delete Cancels a scheduled command. If id is omitted, all the
scheduled commands on the computer are canceled.
/yes Used with cancel all jobs command when no further
confirmation is desired.
time Specifies the time when command is to run.
/interactive Allows the job to interact with the desktop of the user
who is logged on at the time the job runs.
/every:date[,...] Runs the command on each specified day(s) of the week or
month. If date is omitted, the current day of the month
is assumed.
/next:date[,...] Runs the specified command on the next occurrence of the
day (for example, next Thursday). If date is omitted, the
current day of the month is assumed.
"command" Is the Windows NT command, or batch program to be run.

You can make a new shortcut to:
control schedtasks
Name it something easy like "tsks.lnk" and then save it in c:\windows\system32.
You can now press Windows Key + R, then type "tsks" and press Enter and voila. No mouse necessary at that point.
Or in Windows Vista/7/2008, just press Windows Key, then type "tsks" and press Enter.

You can use either TASKSCHD.MSC or CONTROL SCHEDTASKS
Here are some more such commands.

I'm also running XP SP2, and this works perfectly (from the command line...):
start control schedtasks

If you’re asking what I think you’re asking, you can open it by executing this:
explorer.exe "C:\WINDOWS\Tasks\"

Related

Execute CMD from Scheduler Task

I followed below article to set a reminder
https://www.howtogeek.com/136894/how-to-create-popup-reminders-with-no-additional-software/
Task triggered as per specified time but command prompt window doesn't stay open instead it close immediately closed
I put below in Add Argument field
/C TITLE Read How-To Geek Reminder&ECHO.TIMEOUT 120
"press a key to continue" message is not showing for me
Am I missing something?
OS: Windows 10 Enterprise
Just put everything in a .bat file save it into a directory of you preference, and do the Windows task scheduling as shown in the tutorial except calling the CMD and passing arguments just place the path + *.bat file in the Program/Script textbox of the task scheduler.
Cheers

Scheduled task running batch but not exe within the batch

I know there are similar questions already out there, but none of the other solutions seem to help.
Using Windows 7, I have an executable (for this explanation, I am calling it test.exe) that takes a parameter of the current date.
Example when using the run command:
c:\test.exe 12/26/2014
The executable needs to be ran on a daily schedule.
I have the following batch file set up to run the exe with the required parameters:
#echo off
::This batch will be ran daily to start the exe program
set dateFormat=%DATE:~4,2%/%DATE:~7,2%/%DATE:~10,4%
echo Batch started %dateFormat% %Time%>> BatchLogfile.txt
set testfile=C:\test.exe
start %testfile% %dateFormat%
pause
I can run the batch successfully by double-clicking on it in explorer, but when I add it as a scheduled task it does not actually start the exe.
The batch does run and I can see the processes for the cmd and the exe, but the exe "interface" does not pop up. The echo line in the batch writes out to the log file successfully.
On the scheduled task, I am currently using cmd for the program/script and the following params:
/k "C:\test.bat"
I have also tried the following arguments unsuccessfully in the task scheduler:
C:\Windows\System32\cmd.exe
/c start "" "C:\test.bat"
/k start "C:\test.bat"
Is there anything else I should try so that the exe "interface" shows on the screen? Perhaps there is a better way to run the exe other than task scheduler?
If you want to see the GUI for test.exe, then you will need to configure the respective Windows Scheduled Task to "Run only when user is logged on". Of course then the process would only run for the configured user account.
This is available to select in the Security Options section in the General tab of the respective scheduled task.

Task Scheduler failing to Kill Outlook

I have a scheduled task to kill outlook and this task runs with SYSTEM account (Run whenever user is logged or not / Run with highest privileges are marked)
The action is:
- Start a program
- Program/Script: "taskkill/im outlook.exe"
This doesn't work neither with "C:\Windows\System32\cmd.exe taskkill/im outlook.exe"
I get the error:
Task Scheduler failed to start instance "{a394e482-f326-47ad-995e-664f484926e9}" of
"\Close Outlook" task for user "DOMAIN\CA18-0JG5S49$".
Additional Data: Error Value: 2147942403
Any ideas on what to do?
I DO NOT want to use VBS to kill Outlook. It must be done directly with a command.
Thanks.
You need to put a space between taskkill and its arguments. Change
taskkill/im outlook.exe
into
taskkill /im outlook.exe
Basically, taskkill should be in the "Program" field of the task, and /im outlook.exe in the "Arguments" field.
I know this is an old thread, but throwing in something no-one else seems to have mentioned.
Using taskkill /T /im outlook.exe doesn't work the FIRST time, but if you run this command with say 2 emails opened and the reminders box, it will close the reminders box. Run it again, and closes outlook. Sometimes, you have to run it a third time, as it only closes emails on the second attempt, but 3 times is a charm, usually.
Not very consistent, but at a push, you could put the command into the batch file 3 times to give clunky but workable outlook shutdown routine. I've seen similar behaviour with other commands. For instance, rmdir /S doesn't always delete the full directory structure on the first attempt, so when using it in a batch file I would always put it in twice to be sure, to be sure.

running an R script in batch mode without the command prompt popping up

I have a scheduled task (using SCHTASKS) to run every minute.
SCHTASKS /Create /SC MINUTE /MO 1 /TN READSCALE /TR "Rcmd BATCH --vanilla --slave q:\workspace\waga\readScale.R"
On each run command prompt window pops up. It's slightly irritating and perhaps a potential health hazard for people with epilepsy. In Java, one can use javaw.exe (see this thread) that doesn't pop up a command prompt. Is there an equivalent for R?
Kudos to serverfault.com, where some people solved the problem using no external tools at least in two ways. Here's the thread.
First is to write a .vbs script. This requires some knowledge of this scripting language and may not be appropriate for everyone.
The second method is to run the task (as I'm doing) under SYSTEM (and not the currently logged in user).
Ah, Windows... There is a tool called hstart which may help here.

Windows scheduled task

I have created a Windows 7 scheduled task:
schtasks /create /tn MyTask /tr C:\temp\test\MyScript.bat /sc MINUTE
Problem is that this task seems to get executed by Windows but I think it can not find the running BAT script. There is a quick flash window but can't read what the problem is.
On the other hand, if I place the script under Windows/System32 everything works fine.
schtasks /create /tn MyTask /tr C:\windows\system32\MyScript.bat /sc MINUTE
Anyone knows why the second schedule task works compared to the first one?
This whole thing is part of installing a program on a windows machine from a web page. So I would like to have the BAT file installed in its correct directory and not the System32.
Thanks for you help.
C:\temp is a temporary directory may be cleaned by the OS periodically. So you should first check to make sure that batch file is actually there, and then consider moving it to a more permanent location.
Second, have you tried running the task manually from its intended location? That should help you see what the output is. You can also add PAUSE to the bottom of the batch file (as suggested by commenters) to ensure that it stays up long enough for you to see the output.
Some likely problems are:
You're using some resource which is in %windir% via a relative path, which won't work when the batch file is run from a different location.
The scheduled task is running as a different user and doesn't have the proper permissions.
The task is doing something that requires elevation, but the task itself is not set to run elevated.
IIRC, schtasks does not load user profile: Most probably a variable is not set that you need.
Try to prepend your command line (after /tr) with cmd /K. It will make the console kept alive.
HTH

Resources