Tom
Tom

Reputation: 15021

Create a batch file to open CMD and enter a command

I have created a batch file in an attempt to add a scheduled task however when this runs it does not execute the command any ideas?

echo off
Start CMD /k 
From CMD /k SchTasks /Create /SC DAILY /TN “Cache Task” /TR “C:\Temp Batch     Two.bat” /ST 09:00

Any help would be appriciated.

Upvotes: 0

Views: 4297

Answers (1)

Joey
Joey

Reputation: 354406

  • start cmd /k will open a new command window.
  • from is not a command, so will just emit an error message

A batch file is already a sequence of commands to execute. So if you want to execute commands in a batch file, then just do so (and incidentally, use straight quotes instead of typographic ones, as the latter won't work):

SchTasks /Create /SC DAILY /TN "Cache Task" /TR "C:\Temp Batch Two.bat" /ST 09:00

(I also assume the batch file you want to run doesn't contain five spaces.)

Upvotes: 4

Related Questions