Windows Task Scheduler issue

Hello,

I’m running into 2 separate issues when attempting to use Task Scheduler to run a few tasks.

  1. 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?)

  2. 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.


    What is going on here?

Thank you!

-Aaron

It seems you are using a wrong path to the HTML file? Can you record a screencast of what you are doing?

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.

Hi,

With UI.Vision you want task scheduler to call a script in your preferred language which starts the macro and it will start as expected: UI Automation Open-Source Selenium IDE plus additional features, iMacros alternative

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.

And if that isn’t possible, is there any sort of “template” coded file I could use to autostart macros and just swap out the element that is my macro?

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.

Here are some sample scripts: RPA/command-line at master · A9T9/RPA · GitHub

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.

-Aaron

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:

-NoProfile -WindowStyle Minimized "C:\Users\Path\MyScript.ps1"

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?

Try to use vbs to open firefox and from there run macro

Create a .vbs file and put in below code. Use task scheduler to open this vbs file.

dim wshshell

Set wshshell = WScript.CreateObject(“WScript.Shell”)

wshshell.run “”“C:\Program Files\Mozilla Firefox\firefox.exe”" file:///C:/Users/…/ui.vision.html?direct=1&macro=Macro1", 3, False

Set wshshell = Nothing
wscript.quit

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.

image

Add -NoExit to your arguments so the window doesn’t close… you might have an error and it’s closing so fast you can’t see it.

Check the syntax and your CLI parameters in PowerShell. Here is an example:

Start-Process "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "file:///C:/Users/Path/ui.vision.html?direct=1&storage=browser&closeBrowser=1&macro=MyMacro"

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.

Can you attach your VBS or Powershell file here? Or copy it in the forum as source code.

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

That’s good to hear; I will test out pointing to the ui.vision.html file. Need to get a few other things done today and I will try that instead.

Also I’m attaching the vbs and powershell files I’ve been using. I added the new code adding the “press enter to exit” portion.

Here’s what I’m working with currently.
powershell file:

Start-Process -FilePath “C:\Program Files\Google\Chrome\Application\chrome.exe” “file:///C:\Users\aaron\Downloads\startBestbathDealerMap.html?direct=1&storage=xfile&closeBrowser=1&macro=MyMacro”
Read-Host -Prompt “Press Enter to exit”

VBS file

dim wshshell

Set wshshell = WScript.CreateObject(“WScript.Shell”)

wshshell.run “”“C:\Program Files\Mozilla Firefox\firefox.exe”" file:///C:\Users\aaron\Downloads\startBestbathDealerMap.html?direct=1&macro=Macro1", 3, False

Set wshshell = Nothing
wscript.quit

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&macro=“file:///C:\Users\aaron\Desktop\uivision\macros\R+M\Bestbath\Bestbath_Dealer_Map.json”
Read-Host -Prompt “Press Enter to exit”

The macro syntax is wrong… change it to the internal UI.Vision folder path structure. For example, this would be macro=TestFolder/test

screenshot

Also if there is a space in the folder or macro name use %20. For example My Awesome Macro would be My%20Awesome%20Macro