1

I want to set up a task scheduler to run a PowerShell script every 1 hour with no prompt windows pop-up.

Here is the command I tried:

schtasks /create /sc hourly /tn $Task-Name /st $ScheduleTime `
/tr "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -windowstyle hidden -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -command C:\MyScript.ps1" `

I added all parameters I found.

-windowstyle hidden -NoLogo -NonInteractive -NoProfile

The script runs in the background with no problem but it still at the beginning pops up for a second before hides itself.

Does anyone know how to make a task scheduler to run the ps1 script fully hide with no pop-up windows?

2
  • 1
    To run a command script and hide the window from appearing, call the task using VBScript.Run.
    – JosefZ
    Apr 8, 2021 at 10:28
  • @JosefZ I refer to your link and solve the issue by the VBS. Thank you so much! Could you please post the answer below? Then I can accept the answer.
    – ITnewbie
    Apr 8, 2021 at 23:57

1 Answer 1

2

I am achieving this via the task scheduler, i have set the action value to start a powershell program with the following arguments:

-executionpolicy bypass -noninteractive -file "C:\PathToYourScript"

enter image description here

the key argument here is -noninteractive, it does not present an interactive prompt to the user.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.