I have created a task in task scheduler.
Its basically a powershell script which has to run in interactive mode.
Task is running under SYSTEM account.
In Actions tab, under Program/Script I have added path of the ServiceUI.exe e.g, C:**\ServiceUI.exe Under Add arguments option, I have added C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -Windowstyle hidden -NoProfile -Executionpolicy bypass -file "C:**\PS1.ps1"
When I run the task, powershell window prompt shows for a fraction of a second.
Could someone please suggest a way to hide it?
CodePudding user response:
I was able to fix the problem by using vb script.
WScript.Quit CreateObject("WScript.Shell").Run("powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File " & PSscriptPath, 0, true)
In Actions tab, under Program/Script I had path of the ServiceUI.exe e.g, C:**\ServiceUI.exe
Added wscript.exe "vbs script path" in the arguments option.
Powershell prompt doesn't come up, and task works perfectly in interactive mode under SYSTEM account using these options.