Powershell 弹出窗口

2020-1-7

法一:

1
2
$ws = New-Object -ComObject WScript.Shell
$wsr = $ws.popup("你好吗?",5,"我的窗口",1 + 64)

法二:

1
2
3
4
5
6
function Read-MessageBoxDialog
{
$PopUpWin = new-object -comobject wscript.shell
$PopUpWin.popup("Hello World")
}
Read-MessageBoxDialog

法三:Form

法四:VB

个人整理:

雷电模拟器内存耗尽:

1
2
3
4
5
6
function Read-MessageBoxDialog
{
$wsPopUp = new-object -comobject wscript.shell
$wsPopUp.popup("雷电模拟器可用内存即将耗尽,程序正在退出。ERROR_CODE=0000007E",5,"LdBoxSVC",1 + 64)
}
Read-MessageBoxDialog

系统内存耗尽:

1
2
3
4
5
6
function Read-MessageBoxDialog
{
$wsPopUp = new-object -comobject wscript.shell
$wsPopUp.popup("计算机的内存不足。若要还原足够的内存以便程序正常工作,请保存文件,然后关闭或重新启动所有打开的程序。",0,"Microsoft Windows",0 + 64)
}
Read-MessageBoxDialog

系统内存错误:

1
2
3
4
5
6
function Read-MessageBoxDialog
{
$wsPopUp = new-object -comobject wscript.shell
$wsPopUp.popup("''0x0454A2B3''指令引用了''0x00000062''内存,该内存不能为''read''。",0,"Windows",2 + 64)
}
Read-MessageBoxDialog

2020-1-9

若要不显示 ps 窗体,可以加入”-WindowStyle Hidden” 参数,但是弹窗也会被一并隐藏。我们可以使用 bat 调用 vbs 或 js 的 wscript 实现此功能。

1
2
mshta vbscript:CreateObject("Wscript.Shell").popup("Hello,lxmxn",7,"batch script",64)(window.close)
mshta "javascript:new ActiveXObject('WScript.Shell').popup('Hello,lxmxn',7,'batch script',64);window.close();"