# Help Needed to schedule a task thru dos prompt



## kunjikorans (Dec 11, 2008)

I am using Win Xp Sp2 .. 
I have created a file for eg " abc.xyz". How do I schedule to run this file at specific times using dos prompt/command prompt? 

I want to run this file --- c:\abc.xyz at specific times and daily ..

Can anybody show what should be typed specifically in the cmd prompt??


Regards,
Sachin


----------



## TheOutcaste (Aug 8, 2007)

*AT 13:05 /every:M,T,W,TH,F,S,SU c:\abc.xyz*

Runs the file at 1:05 PM every day
For multiple times you have to create a new job for each time.
Days of the week can be a day *M*,*T*,*W*,*Th*,*F*,*S*,*Su* or a number *1-31*
* AT /?* in a command prompt for syntax

Or use *SCHTASKS*:

*SCHTASKS /Create /SC DAILY /RU user /RP password /ST 13:00:00 /ST 15:00:00 /TN MyFile /TR C:\abc.xyz*

This runs the task under the *user* account at 1PM and 3PM every day.
* SCHTASKS /?* or *SCHTASKS /Create /?* in a command prompt for syntax

Also see Command-line reference A-Z

HTH

Jerry


----------



## kunjikorans (Dec 11, 2008)

Hi Jerry,
Thanx for ur help...
Let me be more specific ..
I am the administrator, I have no other usernames ... and no passswords when I loggon to windows. I want to run a batch file that i have created.. cing.bat. 

I want this file to run everyday from 2am to 5pm at every 15 mins interval. 
I tried ur suggestions but it didnt work


----------



## TheOutcaste (Aug 8, 2007)

kunjikorans said:


> and no passswords


There's the problem. You must have an account with a password to be able to schedule a task, at least using *schtasks* or *Control Panel | Scheduled Tasks*. I've never tested the AT command to see if you have to have a passworded account to create a job. The actual job it creates uses the system account so I wouldn't think it necessary, but you'd have to create 60 jobs to use the AT command.

Is there a reason this has to be done from the command prompt?

You can create a task using the Task Scheduler and just point it to the batch file. Much easier than trying to use the command line.
If you want it to run minimized, you have to create a shortcut to the batch file and set it to run minimized. It will still appear on the taskbar.
To hide it completely, you'd need to use a 3rd party app like Hidden Start or use VBS.

* Schtasks* will work to create the task, but you can't specify an end time. You'd have to edit the schedule by using *Control Panel | Scheduled Tasks*
This will create the task, then you can add the *Run Until* time via *Control Panel | Scheduled Tasks*
*SCHTASKS /Create /SC MINUTE /MO 15 /ST 02:00:00 /TN PingTest /TR C:\ping.bat*

You can create another user account that is a Computer Administrator and give it a password. However, if you are currently using the Built-in Administrator account as your main account, it will vanish from the Welcome screen as soon as you create another account.

You can add a password to your current account, then set windows to login to that account automatically.

HTH

Jerry


----------



## WWarrior (Dec 14, 2008)

TheOutcaste said:


> There's the problem. You must have an account with a password to be able to schedule a task, ...


Hi Jerry - That's not exactly correct.

He can execute this vbs script which negates the need for a password login to run a scheduled task.

The code is here:


```
Option Explicit

Dim WSHShell, n, MyBox, p, itemtype, Title

Set WSHShell = WScript.CreateObject("WScript.Shell")
p = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\"
p = p & "limitblankpassworduse"
itemtype = "REG_DWORD"
n = 0

WSHShell.RegWrite p, n, itemtype
Title = "Your Scheduled Tasks Can Now be Run without a Password." & vbCR
Title = Title & "You may need to log off/log on" & vbCR
Title = Title & "For the change to take effect."
MyBox = MsgBox(Title,4096,"Finished")
```
Save that as a vbs file EG: NoPassword.vbs

You can now run scheduled tasks without a password.

kunjikorans - If you like, your batch file could be tweaked to run once only, then stay running, and have a timer / checker built into it which could do the same thing - fire every 15 minutes - it would mean the Dos window remains open all the time but would save the scheduling entries.

You could capture the time and place it into the environment, then read that at set times within the running batch file. A wait commend could be added to make it fire exactly when you wanted. This way, you could kick it off either using scheduler or merely have it in the start up group and run it all the time - only have it execute your commands within the time frame you specify. I have nearly the exact same need and run a similar batch file all the time on my machine using this method. It's very simple to do.


----------

