2016-08-08 13 views
0
[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スクリプトを実行すると、タイトルとメッセージを変更するパラメータを持つバッチファイルからポップアップバルーン通知を表示できますか?バッチファイルからpowershellを実行しています

+0

Powershellをバッチスクリプトで使いたい場合、起動するには 'powershell'を使い、終了するには' exit'を使います。出入りの間に行われるすべては、通常のパワーシェルのように扱われます。 –

答えて

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) 

ルックを行うことができます:ちょうどPS株では通常%交換%値を使用する任意のパラメータを変更するためには

@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) 

。これらの行は長いバッチ行として評価され、、次にがPowerShellコマンドとして実行されることに注意してください。同じ理由で、引用符の前にバックスラッシュを付ける必要があります。

+0

こんにちはAacini、それは非常にうまくいっている応答する時間をとっていただきありがとうございます。 – Marsi63

+0

そのような場合、チェックマークを選択してこの回答をアップボートすることができます... – Aacini

関連する問題