Jump to content
kawliga751

schtasks to run script at set time every weekday

Recommended Posts

I am attempting to run an Autoit.exe with schtasks every weekday @ 9:05 am.

I have the below

C:\>SchTasks /Create /TN "P10Run" /TR "O:\AUTOIT\P40 Run.au3" /SC WEEKLY /D MON,
TUE,WED,THU,FRI /ST 09:05:00
SUCCESS: The scheduled task "P10Run" has successfully been created.

I also did a "test" run :

C:\>Schtasks /Run /TN "P10Run
SUCCESS: Attempted to run the scheduled task "P10Run".

But when I run my query to verify success my "Last Result" seems to indicate that the script did not run:

C:\>SCHTASKS /QUERY /FO LIST /V /TN "P10RUN"

Folder: \
HostName:                             xxxxxxxxxxxxxxxx
TaskName:                             \P10RUN
Next Run Time:                        N/A
Status:                               Could not start
Logon Mode:                           Interactive only
Last Run Time:                        6/14/2017 9:08:56 AM
Last Result:                          -2147024894
Author:                               xxxxxxx
Task To Run:                          O:\AUTOIT\P40 Run.au3
Start In:                             N/A
Comment:                              N/A
Scheduled Task State:                 Enabled
Idle Time:                            Disabled
Power Management:                     Stop On Battery Mode, No Start On Batterie
s
Run As User:                          xxxxxxxxx\xxxxxxxx
Delete Task If Not Rescheduled:       Enabled
Stop Task If Runs X Hours and X Mins: 72:00:00
Schedule:                             Scheduling data is not available in this f
ormat.
Schedule Type:                        Weekly
Start Time:                           9:05:00 AM
Start Date:                           6/14/2017
End Date:                             N/A
Days:                                 MON, TUE, WED, THU, FRI
Months:                               Every 1 week(s)
Repeat: Every:                        Disabled
Repeat: Until: Time:                  Disabled
Repeat: Until: Duration:              Disabled
Repeat: Stop If Still Running:        Disabled

C:\>

Is there something missing in my command? Also is there a better way to make sure that the script does in fact sun successfully?

Thanks In Advance! 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By ces1a
      ;This script will calculate the Nth weekday of any month. Just replace the numbers for $Year, $Month, $Week, and $Weekday with numbers of your choice,
      ;Some lines are not really needed but are there to allow testing and proofing. It is based on Excel formula.
      #include <Date.au3>
      Global $tmp, $Year = "2019", $Month = "2", $Week = 2, $WeekDay = 4
      Global $aNth = StringSplit("First  ,Second ,Third  ,Fourth ,Fifth  ", ",")
      Func GetWeekDay($Week, $Year, $Month, $WeekDay)
          Local $LastDay = 8 - $WeekDay, $EndDay = $Week * 7 + 1
          $Month = $Month > 10 ? $Month : "0" & $Month
          Local $iWday = _DateToDayOfWeek($YEAR, $Month, $LastDay)
          Return $YEAR & "/" & $Month & "/" & $EndDay - $iWday
      EndFunc
      MsgBox(0,'',$aNth[$Week] & _DateDayOfWeek($WeekDay) & " of " & _DateToMonth($Month) & _
          " " & $Year & " is  " & GetWeekDay($Week, $Year, $Month, $WeekDay) )
       
      GetNthWeekDay.au3
    • By AnonymousX
      So I just got a new computer, and instantly went and installed Autoit onto it. I selected run script as default action when clicking on an au3 file, however every time I do this it opens the script in the editor. I can from there run the script no problem.
      I've tried reinstalling and checking the settings by hitting "Ctrl+1" and have confirmed it is set to run, but yet it just continues to open in the editor.
      Any ideas why this is happening or how to solve?
      New system is windows 10, old was windows 7
    • By ademon
      Hi. I can open the editor with out problems but I can not compile because it is placed on another partition diferent from C.
      Can you provide an update of this bug?


    • By lenclstr746
      Hi guys,
      Some functions of my script are running slowly. Very slow. What is the reason?
      My Code:
      <snip>
    • By HariKara
      Hi AutoIters!
       
      Im trying to launch a .exe file that is nested within the program files (x86) folder structure. i have already used the standard RunAs Syntax and found that it fails to launch the application. I have switched to Run and that seems to work. My issue is I have to use RunAs as the applicaton would need to run under a completely different account. The Current logged in user is a Local User on the machine, however, the application must be run as a domain user. The Machine is domain connected.
       
       have tried the following:
      RunAs("username","logonpassword", $RUN_LOGON_PROFILE, "D:\Program Files (x86)\Vendor\Application Name\Exe Location\Executable.exe") The above fails to launch, there are no errors or syntax issues, it just does nothing when the variables are replaced for the correct values.
      I did the same using the Run command
      Run("D:\Program Files (x86)\Vendor\Application Name\Exe Location\Executable.exe") That seems to work fine, but runs in local user context. Any thoughts? Could it be a local Machine rights issue? Or have i missed something glaring in my script
×
×
  • Create New...