Link to home
Start Free TrialLog in
Avatar of sda100
sda100Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Using the "AT" command, what is the syntax to run a task, now?

I thought it was something like at +1 "cmd.exe", but the syntax is wrong.  How can I create a one-off task to run asap?

Thanks,
Steve :)
Avatar of Kalti
Kalti

I'm i little confused by your question, however, you can set it to run at a certain time 'AT 11:30 cmd.exe' will run cmd.exe at 11:30 of the current day, so just change the time to one minute away from the current time...

If you want to run a task 'now' then, you just run it, no real point in scheduling it?

If the task is already schduled, you will see it in Scheduled Tasks under control panel, where you can right click on it and click "Run" any time you like...
Avatar of sda100

ASKER

Oh, there is most definately a point for using AT... I want the program to run with SYSTEM privileges ;)

Rather than haivng to spend 3 secs and a bit of brain power to calculate the time, I just want to run it asap, which I'm pretty sure could be done with the AT command by specifying 1 minute ahead of NOW.  I just can't remember :(

Steve :)
Ah, i see, well sorry mate, i have never heard of a way to do it and i just did a search around and couldn't find anything in any help documents for the command.

But, good luck, and if you find a way be sure to post it up :)
ASKER CERTIFIED SOLUTION
Avatar of Chris Phillips
Chris Phillips
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
HI sda100,

I'm assuming that you are using a current version of windows (xp/2k/2k3)

you can set a scheduled task to run with a user account - an admin will have system priveleges.. it's probably easier to do this with the GUI than with the cmdline version: RUN NOW is an option when you set up the job schedule.

then if you need to fire the job again rather than by schedule, open the scheduled tasks folder and click 'run now'

when you create the job, you can enter advanced options - if this is for a monitoring job, you can use recurrence (eg run every 5 mins from 6am - 8pm or whenever, and kill if job doesn't end in, say, 4 minutes)

local security policy will tell you who can schedule tasks.. perhaps look there if a specific account isn't scheduling correctly.

:)
Hi,

http://www.robvanderwoude.com/index.html

Gives you all the details on the AT command. And yes it will run using the system account.

cheers

S
AT now + 1 minute run command.com
Depends on the OS

For XP it would be more like AT \\YOURMACHINE 9:15 /interactive CMD
If this is on Windows machine (as implied by the use of AT) then why not use the RUN AS command to initiate system privailages?
Alternatively, you can use the system variable for the current time which is %TIME%. Using a third party (or grep) tool, you can extract the hh:mm part and then add a couple of minutes to it, then push this variable into the AT command.

set fred = %TIME%
Set jon = LEFT$(%fred%,5)+1
at %jon% yourjob.exe

Does this make sense? The LEFT$ won't work in DOS btw. Just an example.

Barny
because you would have to know the system password to use the runas command
If you were to use the Task Scheduler, you could define a time to run the task at, and if for some reason you need to immediately execute the task, you can run it by right-clicking it and selecting 'run'
Why not run the soon command? It too should have system privilege

C:\>soon

-----------------------------------
SOON  :  Command Scheduling Utility
-----------------------------------

Usage : SOON [\\computername] [delay] [/INTERACTIVE] "command"
   or : SOON /D [/L:n] [/R:n] [/I:{ON|OFF}]

delay : the number of seconds from now when the scheduled job should start.

   /D : modify Default settings and/or display their current values.
   /L : set LocalDelay - default delay for Local jobs - initially 5 seconds.
   /R : set RemoteDelay - default delay for Remote jobs - initially 15 seconds.
   /I : set InteractiveAlways option - initially OFF.

SOON schedules a job to run in the near future, a number of seconds from now.
SOON closely resembles the AT command because SOON simply runs a suitable AT
command. For a details of the other arguments run "AT /?" without the quotes.

Examples : SOON CMD /C C:\JOBS\BATCH.CMD
           SOON 10 CMD /C C:\JOBS\BATCH.CMD
           SOON \\SERVER 60 /C \JOBS\BATCH.CMD
           SOON \\SERVER /INTERACTIVE CMD /C C:\JOBS\BATCH.CMD
           SOON /d /l:2 /r:30 /i:on

Current Settings :     InteractiveAlways = OFF
                    LocalDelay (seconds) = 5
                   RemoteDelay (seconds) = 15
closed