I’m running into 2 separate issues when attempting to use Task Scheduler to run a few tasks.
When attempting to start the macros with task scheduler (as exported HTML auto-run files), it always stops to ask what program to use to open the HTML files (chrome is already set by default so why is it stopping to ask the user?)
Even when I manually click to start in chrome, I just get the error in the screenshot. However if I manually open the macro is opens just fine in chrome without throwing the error.
Here is all I am attempting to do. I do not understand how the path can be wrong when I am literally clicking on the autorun file as the file I would like to run. Should be pretty cut and dry…what is going on here???
Again; I’d also like to skip the dialogue that comes up asking what program to use. HTML files by default are set to start using Chrome so why does it keep asking me? This occurs if I allow the HTML file to autostart based on the scheduled time for the macro or when I manually run the action as seen in the clip.
I see. Is it not possible to just start the html files directly? I’m just familiar with coding like this. I will look into this but it’d be much, MUCH easier to just start via autostart HTML files.
I’m not sure but for reliability I would have task scheduler start the script. All of my unattended macros start this way and I’ve never had any issues.
The script can even just be a simple one line start for your macro but the main advantage of using a script is you can add conditions, run more than one macro, check if completed, etc.
This is great! I actually just found this page you are referring to and managed to figure out the 1 line of code method using powershell. Learning alot in a really short period of time here!
So I just got the “1 liner” version of this working. The line of code opens chrome, and then opens the macro and it works.
However, when I run this .ps1 file in Windows Task Scheduler it asks me what program to use (this should automatically just open in powershell) and even if I manually click on PowerShell in the list, it just opens for a split second before closing and processing none of it. Any thoughts on that?
Really appreciate your help on this btw!! This is soooo close to working correctly.
Use “Create Task” instead of “Create Basic Task”. For program to start put in powershell.exe (or pwsh.exe if using PowerShell v6 or above).
You’ll put in the path to your script and your arguments in the “Add Arguments (optional)” section like so:
I see! Extremely close to working now but not quite; I set it up the way you have it (mine uses powershell.exe) and I copied the argument you made but replaced the directory with where my powpershell file is located. Now it bypasses the “What program do you want to use” window and goes straight to powershell.
However now it minimizes and then instantly closes out before accomplishing the task. Basically a similar behavior to before but I am able to see the minimize animation right before it closes out. Are .ps1 files not good for this? Should I be exporting as one of the other powershell extensions?
Hm. I attempted to do what you said Tomas and got this error. I’d love for either the powershell script or this to work. Ugh I am SO close. I wonder what’s going on.
Added your code to the powershell file and the argument to task scheduler but it still closes without displaying any text. The windows does stay up a bit longer before closing though. The file still runs as expected when starting it manually though.
I currently have the script pointing towards the auto start html file I exported that is the name of the macro. Should I be pointing it to the ui.vision.html file instead? I understand there is a different file it can output that is a more general autorun file.
Also important to note I’m actually running a macro that is locally stored, on the hard drive, not browser.
Not sure why it is still closing like that. Add this to the end of the script, which should force it stay open:
Read-Host -Prompt "Press Enter to exit"
Yes, it’s best practice to point to ui.vision.html then add your macro you want to start to macro= . Since your macro is on the hard drive, you would use storage=xfile
Ok change it to point to ui.vision.html and I noticed you have macro=MyMacro which I used as an example and needs to be the name of your real macro there including the path. For example macro=MyFolder/MyMacro
Alright. I’ve updated the script. For some reason it is not able to complete. I updated the path to ui.vision.html and the macro to the macro in the primary UI vision folder. Also changed storage to refer to xfile.
When I reference the macro itself I want to go to the actual folder UI Vision stores the local macros correct? (since I’m using Local storage). Or do I need to refer to the exported auto-run html file? My gut feeling upon looking at this is I need to reference the actual folder UI Vision keeps its macros in which I currently have on my desktop.
Start-Process -FilePath “C:\Program Files\Google\Chrome\Application\chrome.exe” “file:///C:\Users\aaron\Downloads\ui.vision.html”?direct=1&storage=xfile&closeBrowser=1¯o=“file:///C:\Users\aaron\Desktop\uivision\macros\R+M\Bestbath\Bestbath_Dealer_Map.json”
Read-Host -Prompt “Press Enter to exit”