forms - Powershell 在控制台和 ISE 中形成应用程序不同的输出
问题描述
我在 powersheel 中创建了复杂的表单应用程序,它也在 Powershell ISE 和 powershell 控制台中正常运行,但行为几乎没有区别:当我通过在 Windows 资源管理器中双击运行应用程序时,powershell 控制台打开,但有太多“调试”创建所有表单控件(复选框、标签、按钮...)的数据。启动时间太长,看起来像这样:
TextImageRelation : Overlay UseMnemonic : True UseCompatibleTextRendering : True UseVisualStyleBackColor : True AccessibilityObject : ControlAccessibleObject: Owner = System.Windows.Forms.CheckBox, CheckState: 0 AccessibleDefaultActionDescription : AccessibleDescription : AccessibleName : AccessibleRole : Default AllowDrop : False Anchor : Top, Left AutoScrollOffset : {X=0,Y=0} LayoutEngine : System.Windows.Forms.Layout.DefaultLayout BackgroundImage : BackgroundImageLayout : Tile BindingContext : {} Bottom : 208 Bounds : {X=165,Y=190,Width=96,Height=18} CanFocus : False CanSelect : False Capture : False CausesValidation : True ClientRectangle : {X=0,Y=0,Width=96,Height=18}
此输出不在 powershell ISE 中(没有) - 应用程序立即启动。
我无法解决此问题,如果可能的话,我想在从控制台运行时删除调试输出 - 以加快脚本启动。
脚本源代码与互联网上的示例相同,例如: https ://docs.microsoft.com/en-us/powershell/scripting/samples/creating-a-custom-input-box?view=powershell-7
我试过哟添加| Out-Null 到一些控件/行 - 我在日志中看到,但它没有帮助。
我还尝试通过手动向控制台添加一些控件来确定哪个命令正在输出,但没有一个生成该输出。
我尝试创建 ISE 配置文件并将其加载到从控制台运行的脚本中,但没有帮助,因为创建的配置文件是空的。
如果我像这样运行新的控制台窗口:
start-process powershell -argumentlist "-noexit", "-noprofile"
并从中运行脚本,它可以在没有日志的情况下工作。但是如果我像这样运行脚本:
start-process powershell -argumentlist "-noexit", "-noprofile", "-command $path"
它会再次输出日志。
任何想法如何做到这一点?我应该检查/修改什么。
谢谢你。
解决方案
已解决:问题是我在评论中提到的脚本名称中的空格。
推荐阅读
- docker - Apache2.4.20 编译错误:/usr/bin/ld: 找不到 -lssl 和 -lcrypto
- python - 如何在固定间隔内平均一列?
- flutter - 如何在 Flutter Navigation 中使用 Bloc?
- javascript - 使用 Puppeteer 和 Node.JS 在网站上的 iFrame 中找不到隐藏的输入元素
- vue.js - 当我尝试嵌套本地组件时,为什么会出现错误 [Unknown custom element: did you register the component?]?
- reactjs - 如何动态导入图片
- php - 在 WooCommerce 中设置总订单的最小体积和重量
- javascript - 从外部 URL 读取文件
- ajax - 基于搜索栏中用户输入的不同查询参数
- python - 如何在pytorch中标准化卷积权重?