如何在不显示窗口的情况下运行 PowerShell 脚本? [英] How to run a PowerShell script without displaying a window?
问题描述
如何在不显示窗口或任何其他符号的情况下运行 PowerShell 脚本用户?
How is it possible to run a PowerShell script without displaying a window or any other sign to the user?
换句话说,脚本应该在后台安静地运行,不给用户任何迹象.
In other words, the script should run quietly in the background without any sign to the user.
不使用第三方组件的答案加分:)
Extra credit for an answer that does not use third party components :)
推荐答案
你可以像这样运行它(但这会显示一个窗口):
You can either run it like this (but this shows a windows for a while):
PowerShell.exe -windowstyle hidden { your script.. }
或者您使用我创建的帮助文件来避免名为 PsRun.exe 的窗口正是这样做的.你可以下载源码和exe文件在 PowerShell 中使用 WinForm GUI 运行计划任务.我将它用于计划任务.
Or you use a helper file I created to avoid the window called PsRun.exe that does exactly that. You can download source and exe file Run scheduled tasks with WinForm GUI in PowerShell. I use it for scheduled tasks.
已正如 Marco 指出的,此 -windowstyle 参数仅适用于 V2.
Edited: as Marco noted this -windowstyle parameter is available only for V2.
这篇关于如何在不显示窗口的情况下运行 PowerShell 脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!