Share via


Run a powershell script without a console window (at all)

Question

Saturday, January 20, 2018 6:15 PM

I wrote a script that sends data over COM to Arduino, and I'm planning to schedule this script to run every 5 seconds or so. I know there are a few ways to make the script run without a console window, but all the ways I've seen still pop the cmd window for a split second and then hide it. That's pretty annoying when that happens once every 5 seconds, and even more annoying when it folds full screen applications (video games for instance).

So is there a way to launch a script without console at all?

All replies (5)

Saturday, January 20, 2018 6:34 PM | 1 vote

If it is run as a task it will not show a window.

\(ツ)_/


Saturday, January 20, 2018 6:36 PM | 1 vote

You can also run it as a PowerShell scheduled job.

/en-us/powershell/module/PSScheduledJob/Register-ScheduledJob?view=powershell-5.1

\(ツ)_/


Saturday, January 20, 2018 7:20 PM

I've had this problem with a login script using task scheduler.  I've used vbscript run with a windows style of 0 (hidden).  https://ss64.com/vb/run.html


Saturday, January 20, 2018 8:02 PM

Why does it have to be a login script?  I don't recommend running login scripts.  Use Group Policy to manage users.  Login scripts are seldom needed in modern Windows and GP is more manageable. 

In current versions of Windows the login scripts should always be deployed via Group Policy and they won't show a Window if there is no console output.

\(ツ)_/


Saturday, January 20, 2018 11:25 PM

Have you also tried invoking it from a batch file as well? I mean you create a batch file mybatfile.bat and inside it, you then call up your PowerShell file by using

PowerShell.exe -File c:\temp\mypsfile.ps1 -ExecutionPolicy Bypass -WindowStyle Hidden -noProfile -noInteractive