Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
schtasks and QM
#1
I'm trying to schedule a task using RunConsole2 to launch schtasks with a command line to create a scheduled task that will run a QM function.

The problem is getting it to create the right "TaskRun".

It needs to be=
"c:\program files\quick macros 2\qmcl.exe" T MS "{tr}""

But get return error:
ERROR: Invalid Argument/Option - 'T'.
Type "SCHTASKS /CREATE /?" for usage.


Function ScheduleOnce
Code:
Copy      Help
function int'mm str'tn str'tr

;EXAMPLE
;ScheduleOnce 1 "Test" "Function3"

;;Adds number of minutes from now to schedule task
DATE d.getclock
d=d+(6.9444444444444444444444444444444e-4*mm)

;;Deletes old task if couldn't run.
;;Create task will fail if task with same name exists
str Del=
F
;schtasks
;/Delete
;/TN {tn}
;/F
Del.findreplace("[]" " ")
Del.trim
RunConsole2(Del str'out1)
out out1

;;Defines time to run for command line formatting
str st.timeformat("{HH}:{mm}:{ss}" d)
str sd.timeformat("{MM}/{dd}/{yyyy}" d)

;;Formats schtasks command line
str cl=
F
;schtasks
;/create
;/tn {tn}
;/tr "c:\program files\quick macros 2\qmcl.exe" T MS "{tr}""
;/sc once
;/st {st}
;/sd {sd}
cl.findreplace("[]" " ")
cl.trim

RunConsole2(cl str'sout)
out sout
#2
Quote:When scheduling a task that executes a file where the path or file name has spaces you need to use escaped double quotes ( \" ) around the <path>\<filename> and regular double quotes around the entire command itself. So to open c:\test.doc using MS Word structure your command as follows:

schtasks /create /tn "My App Job1" /tr "\"C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE\" C:\text.doc"
/sc DAILY /st 05:00:00 /ru <username> /rp
<password>
Found here: http://msdn.microsoft.com/en-us/library ... 85%29.aspx


Function ScheduleOnce
Code:
Copy      Help
;;Formats schtasks command line
_s.searchpath("qmcl.exe")
str cl=
F
;schtasks
;/create
;/tn {tn}
;/tr "\"{_s}\" T MS \"{tr}\""
;/sc once
;/st {st}
;/sd {sd}
cl.findreplace("[]" " ")
cl.trim
#3
Exactly what I needed. Thanks.


Forum Jump:


Users browsing this thread: 1 Guest(s)