Windows Task Scheduler issue

I updated that! Somehow STILL not working but I feel like I am incredibly close. Not sure why but this still does not work. I checked and the ui.vision.html file is in that location and I updated the path to the macro.

Btw I REALLY appreciate you helping me out with this!! Has been incredibly informative. There’s gotta be 1 thing I’m missing here but I’m not even sure what it could be at this point.

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=Bestbath/Bestbath/Bestbath%20Dealer%20Map"
Read-Host -Prompt “Press Enter to exit”

image

No worries at all, glad to help! This is a great forum and community.

It looks like by the screenshot it should be macro=Bestbath/Bestbath%20Dealer%20Map
not
macro=Bestbath/Bestbath/Bestbath%20Dealer%20Map

Haha…updated the macro=Bestbath/Bestbath%20Dealer%20Map portion but it STILL doesn’t work. So frustrating because I’m SO close to having this work. Anything else that could potentially be the issue??? I seriously feel like there is just 1 more piece to the puzzle missing and I’m messing it up somewhere.

Currently powershell pops up for about 1.5 seconds and closes. And I’m not seeing the “Press Enter to exit” text. (same as it was before I corrected the macro’s path).

Ok we need to narrow down where the issue is.
1 - Put the Start-Process command in the PowerShell terminal and run. Does it work then?

2 - In the script just have the Read-Host line and nothing else and start by Task Scheduler and what is the behavior?

Putting the start-process portion in powershell does nothing.

Oddly enough, if I run the Read-Host line by itself that works fine, but when attempting to run via task scheduler it does not.

Ok, leaving just the Read-Host line, add these arguments in Task Scheduler:
-NoProfile -ExecutionPolicy Bypass

If after adding those and it still doesn’t start from Task Scheduler, then try to add -File or -Command (individually, not both at the same time)

Hmm. Still no good, just tried adding all of those (tested -File and -Command separately too). I’m wondering if my syntax here is bad? Currently the Windows Task Scheduler argument is:

-Command-NoProfile -ExecutionPolicy Bypass-NoExit-NoProfile -WindowStyle Minimized “C:\Users\aaron\Desktop\UI Vision Automations\Working Template.ps1”

Also just noting that the .ps1 on its own displays the Press enter just fine when I run it through Powershell directly. The fact that powershell briefly pops up makes me believe the file reference in task scheduler is correct or else it wouldnt know to even use powershell. So there’s that.

There needs to be spaces between the arguments like so -NoProfile -Command
NoProfile is in there twice as well and you can take out -NoExit and -WindowStyle Minimized

We need to get it to start first then work on the other stuff

I see where you’re going with this. Narrowing down what the actual problem is with task scheduler. I’ve updated the argument to this but I’m still getting the same result of the powershell window quitting in ~1 second.

-Command -ExecutionPolicy Bypass -NoProfile “C:\Users\aaron\Desktop\UI Vision Automations\Working Template.ps1”

Does that look right to you?

Exactly.
So now we know the issue is with Task Scheduler and not UI.Vision. That syntax is correct

In Task Scheduler for this task check that you have “Run only when user is logged on” is checked and temporarily for now check “Run with the highest privileges”

Just tried that. Same result.

Edit: I also just tested in all 3 of the “Configure for” modes. Same result.

The only line in the script is the Read-Host line, correct?

In your PowerShell terminal, what is the ouput of Get-ExecutionPolicy -List

This is the only line. And again this does work if I run powershell manually.

Read-Host -Prompt “Press Enter to exit”

I ran that line and got this in return:

    Scope ExecutionPolicy
    ----- ---------------

MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Undefined

Ok we are getting somewhere.

Run this and then try to run w/ Task Scheduler again:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

Alright so I just updated this. Still got the same result of powershell closing right away, but now when I check the ExecutionPolicy it says “LocalMachine RemoteSigned” instead of Undefined.

I spoke to soon ha

In Task Scheduler if you just put in Start a program and then notepad.exe in the Program/Script area does notepad open?

Yep! Just made a new task and all I did was select notepad.exe and it starts just fine when I run the command in Task Scheduler. So task scheduler appears to be working.

Open a CMD window and enter powershell.exe "C:\Users\aaron\Desktop\UI Vision Automations\Working Template.ps1"

does it start that way?

…and screenshot your “Edit Action” screen in Task Scheduler please

I get this error when running in cmd. Pretty sure it has to do with the space in the file name. I just tried adding %20 for all of the spaces after UI and I still get this error?

C:\Users\aaron\Desktop\UI : The term ‘C:\Users\aaron\Desktop\UI’ is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1

  • C:\Users\aaron\Desktop\UI Vision Automations\Working Template.ps1
  •   + CategoryInfo          : ObjectNotFound: (C:\Users\aaron\Desktop\UI:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    

And here is the screenshot:

copy+pasting the fields that are too small to display:

Program/script

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

Add arguments (optional):

-Command -ExecutionPolicy Bypass -NoProfile “C:\Users\aaron\Desktop\UI Vision Automations\Working Template.ps1”