[VOID] [reflection.assembly]::loadwithpartialname("System.Windows.Forms ");[reflection.assembly]::loadwithpartialname ("System.Drawing")
$notify = new-object system.windows.forms.notifyicon
$notify.icon = [System.Drawing.SystemIcons]::Information
$notify.visible = $true
$notify.showballoontip(10,"Operation Complete","All updates have been installed.",[system.windows.forms.tooltipicon]::None)
是否可以运行此powershell脚本以显示带有参数的批处理文件的弹出气球通知,以更改标题和消息?
答案 0 :(得分:0)
你可以做到
@ECHO OFF
PowerShell.exe
[VOID] [reflection.assembly]::loadwithpartialname("System.Windows.Forms ");[reflection.assembly]::loadwithpartialname ("System.Drawing")
$notify = new-object system.windows.forms.notifyicon
$notify.icon = [System.Drawing.SystemIcons]::Information
$notify.visible = $true
$notify.showballoontip(10,"Operation Complete","All updates have been installed.",[system.windows.forms.tooltipicon]::None)
查看http://www.howtogeek.com/204088/how-to-use-a-batch-file-to-make-powershell-scripts-easier-to-run/
答案 1 :(得分:0)
这有效:
@echo off
setlocal EnableDelayedExpansion
PowerShell.exe ^
[VOID] [reflection.assembly]::loadwithpartialname(\"System.Windows.Forms\"); ^
[reflection.assembly]::loadwithpartialname(\"System.Drawing\"); ^
$notify = new-object system.windows.forms.notifyicon; ^
$notify.icon = [System.Drawing.SystemIcons]::Information; ^
$notify.visible = $true; ^
$notify.showballoontip(10,\"Operation Complete\",\"All updates have been installed.\",[system.windows.forms.tooltipicon]::None)
要更改任何参数,只需使用PS行中通常的%replacement%值。请记住,这些行将被评估为长批处理行,然后然后作为PowerShell命令执行。出于同样的原因,所有引号必须以反斜杠开头。