scifigeek64 Posted August 12 Share Posted August 12 Forgive me if this is a stupid question, but I haven't programmed in 15 years and I have forgotten more than I remember about AutoIt. I have a Script that needs to be scheduled to run interactively. It is going to open a web browser, click on a few things, close the browser, then schedule itself to run again the next day, 2 minutes later than it just ran. I can't for the life of me get it to run the task from the Task Scheduler. It will sometimes start Firefox, but it never runs it interactively, so it never actually does anything. It also doesn't seem to have permission to update the schedule to the next day. This is the line in question... RunWait('schtasks /change /tn ScheduledScript /SD $Schdate /ST $Schtime /RL Highest /IT /TR "c:\users\xxxxx\desktop\apps\AutoitScript.exe"') $Schdate and $SchTime are obviously variables with the date and time to run next. If I manually run the script, it does what it is supposed to do until this line when it tells me that I don't have the right permission. (I'm the only user of the PC and have Administrative rights.) I know this isn't much to go on, but does anyone have any ideas? Thanks, Mike Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 12 Moderators Share Posted August 12 Moved to the appropriate forum. Moderation Team Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
rsn Posted August 12 Share Posted August 12 Is the user logged in at the time the scheduled task is triggered? From the help: Quote /IT Enables the task to run interactively only if the /RU user is currently logged on at the time the job runs. This task runs only if the user is logged in. Link to comment Share on other sites More sharing options...
scifigeek64 Posted August 12 Author Share Posted August 12 Yes, I am logged in. I'm the only user of the computer and it is always on. Link to comment Share on other sites More sharing options...
rsn Posted August 12 Share Posted August 12 I re-read your post and I think I missed something the first time. If you're getting a permissions error, your script needs #requireadmin I create/edit scheduled task kind of a lot but I tend to make edits as the system user so I have to shift gears a little when thinking about how other people use it 😅 You may need to post minimum viable code (ex, directives) if the above doesn't work. Link to comment Share on other sites More sharing options...
Nine Posted August 12 Share Posted August 12 @rsn Nice avatar ! rsn 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
rsn Posted August 13 Share Posted August 13 @Nine I was watching Cars with my son and I saw the logo again and thought, oh yeah, I need that! 😁 I'd been without an avatar for like 15 years! Nine 1 Link to comment Share on other sites More sharing options...
scifigeek64 Posted August 13 Author Share Posted August 13 (edited) I thought it was working in my new method but it isn't. This is my new code: RunWait('Schtasks /delete /tn Scriptfile /f') RunWait('schtasks /create /sc daily /TN Scriptfile /SD $schdate /ST $schtime /RL HIGHEST /IT /TR c:\users\xxxxx\desktop\apps\Scriptfile.exe') It deletes the task from the scheduler, but the new task is not created. I have verified that the variables are correct and I had to tell Windows Anti-viirus that it was safe to run files from this directory, but it won't create the new schedule entry. I have tried it from a 2 line script like this: #requireadmin RunWait('schtasks /create /sc daily /TN Scriptfile /SD 08/13/2024 /ST 12:01:00 /RL HIGHEST /IT /TR c:\users\xxxxx\desktop\apps\Scriptfile.exe') If I just run it, it works fine and Scriptfile will run at the time that I specify, but it deletes the scheduled task and no new one is created. Any more ideas? Edited August 13 by scifigeek64 Link to comment Share on other sites More sharing options...
rsn Posted August 13 Share Posted August 13 (edited) So I used you two liner (#requireadmin and the runwait but different exe so it could create a valid task) and it ran with no errors and created the scheduled task. However, I couldn't see the task unless I ran the Task scheduler GUI elevated. See attached: Regular user (non-elevated) on the left. "Run as Administrator" (elevated) on the right. You can see there's more tasks that are invisible (19 additional!) to the non-elevated account. So I can only assume that something is broken with the line with variable-ized values. Edited August 13 by rsn Link to comment Share on other sites More sharing options...
Nine Posted August 13 Share Posted August 13 When you post code, even if it minimal, please use the method shown in the link. By posting one line at a time, it is not helping us one bit. You should post a runable script that we can use as a startup. So you have more chance of getting help... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
scifigeek64 Posted August 14 Author Share Posted August 14 4 hours ago, Nine said: When you post code, even if it minimal, please use the method shown in the link. By posting one line at a time, it is not helping us one bit. You should post a runable script that we can use as a startup. So you have more chance of getting help... Got it. Thanks. Link to comment Share on other sites More sharing options...
Solution scifigeek64 Posted August 14 Author Solution Share Posted August 14 I found the issue. It was all about syntax. I needed to have my variables outside of the single quote for the schtasks. This is what I needed: RunWait("schtasks /create /sc once /TN Scriptfile /SD " & $schdate & " /ST " & $schtime & " /RL HIGHEST /IT /TR c:\users\xxxxx\desktop\apps\Scriptfile.exe") It was really stupid on my part, but at least I finally figured it out. Thanks for the help. Mike rsn 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now