How to schedule a task with the command prompt? - windows

I want to know how to schedule a task using the command prompt.
Now I know you can probably find this on the internet, but I haven't found what I've been looking for.
The problem is that the operating system I have to do it on is in Swedish (Windows Server 2003 in Swedish).
It needs to run a program located at: 'C:\Documents and Setting\Administratör\Skrivbord\Midnight.exe'.
It should run around midnight, every day.
Does anybody know how to schedule this in cmd?
I do have administrator rights, so privileges shouldn't be a problem.

Just use schtasks windows utility in a .bat file or manually in CMD :
schtasks /create /ru Admin /rp paswd /tn "daily work" /tr "C:\Documents and Setting\Administratör\Skrivbord\Midnight.exe" /sc daily /st 23:55:00
Swedish should'nt be a special case :)
off course /ru is the username which we'll be used to run the task

You want the AT command to put an entry in the scheduler service TechNet on AT

Related

How to update a Windows Task Scheduler task from an updater/script running as admin

I'm writing an updater for my application and want to change my "Windows Task Scheduler" task configured by:
schtasks /create /sc once /tn my_task /tr MyApp.exe /rl highest /st 00:00
The updater is running "with highest privileges" and I mainly want to change the path of MyApp.exe.
I've tried:
schtasks /Change /tn my_task /tr MyUpdatedApp.exe (But it asks: Please enter the run as password for... even though the script already runs as admin. And so is not user friendly or even working in my scripted update.)
A powershell script using Get-/Set-ScheduledJob (But it says: A scheduled job definition with Name my_task could not be found. The help text even states Although jobs that are created by using the Register-ScheduledJob cmdlet appear in Task Scheduler, Get-ScheduledJob gets only scheduled jobs. It does not get scheduled tasks created in Task Scheduler.)
How can I updated my scheduled task from my updater/script without user interaction?
I've resorted to exporting and recreating the task using an XML file with the following command:
schtasks /create /f /tn my_task /xml C:\somewhere\my_task.xml
I create the my_task.xml file by exporting it by hand in the GUI and storing it as part of my application.

Creating a batch file to run a command on command prompt as administrator

I would like to create a batch file in order to run a windows command on command prompt as administrator whenever I start the PC.
For example I would like to run the command prompt as administrator and run the command Ping 8.8.8.8 on startup of windows.
Can anyone please explain the full procedures with snapshots?
Thanks in advance
M. Ashraful Haque
You could try something like this create another batch file and add the below command it will run it as the user you specify
#echo off
Runas /env /user:PCNAME\Administrator test.bat
Or
you can add your batch file to the Scheduled task list link below on how to do this. In Scheduled Task you can set what account to use and when it should run.
Change when it runs in create task go to Triggers tab click new and change "Begin the task" to start up
Create Scheduled Task
First with SCHTASKS you can create add a batch file to run as a service and you can give the top privileges , example:
SCHTASKS /Create /TN "Ping My Web Host" /SC HOURLY /TR "C:\services\pinghost.cmd" /RU username /RP password /RL HIGHEST
Here's the documentation documentation and here
And this you'd wanted to read this.

How to Schedule a task with command prompt in windows 7?

I am trying to schedule a task with cmd prompt.The command that I am running is:
C:\Windows\system32\schtasks.exe /CREATE /SC ONLOGON /TN "mytask" /TR "C:\samp.txt" /RU "NT AUTHORITY\SYSTEM" /RP /F
The task is showing in task manager with username as SYSTEM ,and its status is Running with code 0x41301.But it(samp.txt) is not showing in desktop.
The same command if I am replacing the "NT AUTHORITY\SYSTEM" with currently logged on user then it(samp.txt) is showing on desktop.
How can I make the task to display on desktop with /RU "NT AUTHORITY\SYSTEM"
Did you try to add /IT ?
This is the only option which may allow you to display something on the active session using scheduled tasks. However, I am not sure that Windows will allow to interact with the desktop of another user.
Edit : You may use /RU BUILTIN\Users /IT, so any user will be able to run it interactively. What is you constraint on /RU system ?
If your goal is to display the samp.txt file content when a user logs on, another solution is to put the samp.txt in the startup folder of the "all users" start menu : C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
could you try with psexec ?
your command will be something like :
PSEXEC -i -s -d -w c:\ notepad.exe samp.txt

scheduled task onlogon repeat

I need to set a Windows scheduled task that runs at logon and repeats at a given interval (say hourly for this case).
Basically, I want to do this via command line: https://dl.dropbox.com/u/19514611/Capture.PNG
Microsoft's schtasks.exe page (found here: http://msdn.microsoft.com/en-us/library/windows/desktop/bb736357%28v=vs.85%29.aspx) seems to imply you can't set any repetition for an ONLOGON event via command line, but can via the wizard. Is this accurate?
EDIT:
After further research, I've found that I can export this configuration as an XML and build the task using the xml. Is this the way I should go about this? It will require something to parse out and generate a new xml file for each user (less than ideal) and I'd much rather do this via command line.
I realize this thread is old but recently ran into the same issue. The trick is to run a change command after the initial create command. The following will change the task to run every 1 minute.
SCHTASKS.exe /Create /SC ONLOGON /TN "Your Task Name" /TR "c:\path\executableoftask.exe" /RU SomeUser /RP SomePassword
SCHTASKS.exe /Change /RI 1 /TN "Your Task Name" /RU SomeUser /RP SomePassword
SCHTASKS /CREATE /U username /P password /SC ONLOGON /TN "Your Task Name" /TR c:\path\executableoftask.exe /RI HOURLY

how to schedule a non-hidden task with schtasks?

I've been trying to create a scheduled task from the command prompt. The task is created, but it runs hidden. Is there any way of running it in a non-hidden way? The process is very long and I would like to see what is going on...
I'm running it on a Vista, but the task is meant to run on pre-vista OS as well...
SCHTASKS /Create /RU \"NT AUTHORITY\SYSTEM\" /SC DAILY /ST 00:00 /TN Backup /TR \"C:\Sis\Backup\Backup.vbs\" /F /V1
Tks,
Filipe Scur
Running as NT AUTHORITY\SYSTEM means it is a system task and will run hidden.
Try run as a different username.

Resources