PowerShe 消息提示框测试

1. 使用powerShell 弹出一个简单的消息框,代码如下,创建test.ps1脚本文件。

$ConfirmPreference = 'None'
$ws = New-Object -ComObject WScript.Shell
$wsr = $ws.popup("The software has installed successfully, please restart your computer to take effect. Press OK to restart later.",0,"Reboot Attention!",0 + 64) 

执行test1.ps1后,电脑右下角会弹出该消息提示框。

2. 使用VM脚本来提示用户重启电脑,保存脚本为test.bvs, 运行后就可以看到弹出提示框,点yes时,电脑会自动重启:

Dim return 
Set R = CreateObject("WScript.Shell") 
return=MsgBox ("A new software has been installed on your computer, Please restart to take effect.Click OK to restart now, click Cancel to restart later",vbokcancel+vbexclamation,"Attention!") 
If return=vbok Then 
R.run("Shutdown.exe -r -t 60") 
End if

  

 

posted on 2019-04-13 16:05  遠離塵世の方舟  阅读(513)  评论(0编辑  收藏  举报

导航