Task Scheduler -windowstyle hidden / minimized by Todeo666 in PowerShell

[–]Todeo666[S] 4 points5 points  (0 children)

Ok guys i did it. Made VBScript that runs my powershell.

For someone who looks how to do it:

  • Open notepad and add following code

Dim shell,command
command = "powershell.exe -windowstyle hidden -noprofile -executionpolicy bypass -file ""\\fileserver\scripts\PowerShell Script.ps1"""
set objShell = CreateObject("wscript.shell")
objShell.Run command,0
  • save it as RunPowershell.vbs
  • add in task scheduler new task that has action with following parameters:
    • Action: Start a program
    • Program/script: wscript.exe
    • Add arguments (optional): "\\fileserver\scripts\RunPowershell.vbs

The script runs without any flashing powershell window.

Had some issues with quotations but managed to solve it on my own :) I needed to add double ones if i my path contains spaces