我在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",它会再次输出日志。
你知道该怎么做吗?我应该检查/修改什么?
谢谢。
发布于 2020-11-01 01:37:06
解决:正如我在注释中提到的,问题是脚本名称中有一个空格。
https://stackoverflow.com/questions/64580796
复制相似问题