首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >从cmd运行消息框

从cmd运行消息框
EN

Stack Overflow用户
提问于 2014-09-14 18:22:52
回答 3查看 2.5K关注 0票数 3

我正努力做到以下几点:

我需要从批处理文件psh脚本运行,但不是从文件,solo de命令行。我从ps控制台尝试了下面的代码,它可以工作,但是当从cmd传递这段代码时没有。

代码语言:javascript
运行
复制
powershell.exe -ExecutionPolicy Bypass -Command {[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); [System.Windows.Forms.MessageBox]::Show('We are proceeding with next step.')}

有谁能帮忙找出问题吗?谢谢。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-09-14 18:35:44

为“引号”切换{括号}:

代码语言:javascript
运行
复制
@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)

票数 4
EN

Stack Overflow用户

发布于 2014-09-14 19:25:40

Iirc您必须在特定的线程单元模式下运行power shell,才能使win窗体正常运行,因此您需要使用powershell.exe命令行上的相关开关显式指定线程模式。

票数 0
EN

Stack Overflow用户

发布于 2019-06-08 15:36:13

使用语句:

代码语言:javascript
运行
复制
powershell "using assembly system.windows.forms; using namespace system.windows.forms; [messagebox]::show('hi there')"
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25836547

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档