[英]running powershell from batch file
[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脚本来显示批处理文件中的弹出气球通知,并带有用于更改标题和消息的参数?
你可以做
@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/
这有效:
@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命令执行。 出于相同的原因,所有引号都必须带有反斜杠。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.