我正努力做到以下几点:
我需要从批处理文件psh脚本运行,但不是从文件,solo de命令行。我从ps控制台尝试了下面的代码,它可以工作,但是当从cmd传递这段代码时没有。
powershell.exe -ExecutionPolicy Bypass -Command {[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); [System.Windows.Forms.MessageBox]::Show('We are proceeding with next step.')}有谁能帮忙找出问题吗?谢谢。
发布于 2014-09-14 18:35:44
为“引号”切换{括号}:
@powershell.exe -ExecutionPolicy Bypass -Command "[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); [System.Windows.Forms.MessageBox]::Show('We are proceeding with next step.')"(还添加了@ for echo off)
发布于 2014-09-14 19:25:40
Iirc您必须在特定的线程单元模式下运行power shell,才能使win窗体正常运行,因此您需要使用powershell.exe命令行上的相关开关显式指定线程模式。
发布于 2019-06-08 15:36:13
使用语句:
powershell "using assembly system.windows.forms; using namespace system.windows.forms; [messagebox]::show('hi there')"https://stackoverflow.com/questions/25836547
复制相似问题