שאלה | יצירת הודעה של WIN
-
Function Invoke-BalloonTip { [CmdletBinding()] Param ( [Parameter(Mandatory=$True,HelpMessage="The message text to display. Keep it short and simple.")] [string]$Message, [Parameter(HelpMessage="The message title")] [string]$Title="Attention $env:username", [Parameter(HelpMessage="The message type: Info,Error,Warning,None")] [System.Windows.Forms.ToolTipIcon]$MessageType="Info", [Parameter(HelpMessage="The path to a file to use its icon in the system tray")] [string]$SysTrayIconPath='C:\Windows\System32\UserAccountControlSettings.exe', [Parameter(HelpMessage="The number of milliseconds to display the message.")] [int]$Duration=4000 ) Add-Type -AssemblyName System.Windows.Forms If (-NOT $global:balloon) { $global:balloon = New-Object System.Windows.Forms.NotifyIcon [void](Register-ObjectEvent -InputObject $balloon -EventName MouseDoubleClick -SourceIdentifier IconClicked -Action { Write-Verbose 'Disposing of balloon' $global:balloon.dispose() Unregister-Event -SourceIdentifier IconClicked Remove-Job -Name IconClicked Remove-Variable -Name balloon -Scope Global }) } $path = Get-Process -id $pid | Select-Object -ExpandProperty Path $balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($SysTrayIconPath) $balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]$MessageType $balloon.BalloonTipText = $Message $balloon.BalloonTipTitle = $Title $balloon.Visible = $true $balloon.ShowBalloonTip($Duration) #Write-Verbose "Ending function" } Invoke-BalloonTip -Message " TEXT " -Title 'אזהרה!' -MessageType Warningזה הקוד אבל הוא עובד לי רק בpowershell ise אתה יודע איך מפעילים בPOWERSHELL רגיל?
זה השגיאה שאני מקבלAt line:1 char:5 + ) + ~ Unexpected token ')' in expression or statement. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : UnexpectedToken -
Function Invoke-BalloonTip { [CmdletBinding()] Param ( [Parameter(Mandatory=$True,HelpMessage="The message text to display. Keep it short and simple.")] [string]$Message, [Parameter(HelpMessage="The message title")] [string]$Title="Attention $env:username", [Parameter(HelpMessage="The message type: Info,Error,Warning,None")] [System.Windows.Forms.ToolTipIcon]$MessageType="Info", [Parameter(HelpMessage="The path to a file to use its icon in the system tray")] [string]$SysTrayIconPath='C:\Windows\System32\UserAccountControlSettings.exe', [Parameter(HelpMessage="The number of milliseconds to display the message.")] [int]$Duration=4000 ) Add-Type -AssemblyName System.Windows.Forms If (-NOT $global:balloon) { $global:balloon = New-Object System.Windows.Forms.NotifyIcon [void](Register-ObjectEvent -InputObject $balloon -EventName MouseDoubleClick -SourceIdentifier IconClicked -Action { Write-Verbose 'Disposing of balloon' $global:balloon.dispose() Unregister-Event -SourceIdentifier IconClicked Remove-Job -Name IconClicked Remove-Variable -Name balloon -Scope Global }) } $path = Get-Process -id $pid | Select-Object -ExpandProperty Path $balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($SysTrayIconPath) $balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]$MessageType $balloon.BalloonTipText = $Message $balloon.BalloonTipTitle = $Title $balloon.Visible = $true $balloon.ShowBalloonTip($Duration) #Write-Verbose "Ending function" } Invoke-BalloonTip -Message " TEXT " -Title 'אזהרה!' -MessageType Warningזה הקוד אבל הוא עובד לי רק בpowershell ise אתה יודע איך מפעילים בPOWERSHELL רגיל?
זה השגיאה שאני מקבלAt line:1 char:5 + ) + ~ Unexpected token ')' in expression or statement. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : UnexpectedToken@שמח-לעזור לא מצליח להבין. שמרת את הקוד הזה בקובץ ps1 והרצת מפווארשל? זה אמור לעבוד (אני לא יכול לבדוק את זה כרגע לגמרי כי אני במאק כרגע, אז אין לפווארשל יכולת לייבא את
[System.Windows.Forms]בצורה תקינה)
מה שאני כתבתי בקובץ זה זה:Add-Type -AssemblyName Microsoft.VisualBasic Function Invoke-BalloonTip { [CmdletBinding()] Param ( [Parameter(Mandatory=$True,HelpMessage="The message text to display. Keep it short and simple.")] [string]$Message, [Parameter(HelpMessage="The message title")] [string]$Title="Attention $env:username", [Parameter(HelpMessage="The message type: Info,Error,Warning,None")] [System.Windows.Forms.ToolTipIcon]$MessageType="Info", [Parameter(HelpMessage="The path to a file to use its icon in the system tray")] [string]$SysTrayIconPath='C:\Windows\System32\UserAccountControlSettings.exe', [Parameter(HelpMessage="The number of milliseconds to display the message.")] [int]$Duration=4000 ) Add-Type -AssemblyName System.Windows.Forms If (-NOT $global:balloon) { $global:balloon = New-Object System.Windows.Forms.NotifyIcon [void](Register-ObjectEvent -InputObject $balloon -EventName MouseDoubleClick -SourceIdentifier IconClicked -Action { Write-Verbose 'Disposing of balloon' $global:balloon.dispose() Unregister-Event -SourceIdentifier IconClicked Remove-Job -Name IconClicked Remove-Variable -Name balloon -Scope Global }) } $path = Get-Process -id $pid | Select-Object -ExpandProperty Path $balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($SysTrayIconPath) $balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]$MessageType $balloon.BalloonTipText = $Message $balloon.BalloonTipTitle = $Title $balloon.Visible = $true $balloon.ShowBalloonTip($Duration) #Write-Verbose "Ending function" } Invoke-BalloonTip -Message "המחשב יינעל בעוד $messagesubseq שניות" -Title 'אזהרה!' -MessageType Warningתעתיק את זה לקובץ טקסט חדש, תשמור עם סיומת ps1 ותריץ. מה יוצא?
-
@שמח-לעזור לא מצליח להבין. שמרת את הקוד הזה בקובץ ps1 והרצת מפווארשל? זה אמור לעבוד (אני לא יכול לבדוק את זה כרגע לגמרי כי אני במאק כרגע, אז אין לפווארשל יכולת לייבא את
[System.Windows.Forms]בצורה תקינה)
מה שאני כתבתי בקובץ זה זה:Add-Type -AssemblyName Microsoft.VisualBasic Function Invoke-BalloonTip { [CmdletBinding()] Param ( [Parameter(Mandatory=$True,HelpMessage="The message text to display. Keep it short and simple.")] [string]$Message, [Parameter(HelpMessage="The message title")] [string]$Title="Attention $env:username", [Parameter(HelpMessage="The message type: Info,Error,Warning,None")] [System.Windows.Forms.ToolTipIcon]$MessageType="Info", [Parameter(HelpMessage="The path to a file to use its icon in the system tray")] [string]$SysTrayIconPath='C:\Windows\System32\UserAccountControlSettings.exe', [Parameter(HelpMessage="The number of milliseconds to display the message.")] [int]$Duration=4000 ) Add-Type -AssemblyName System.Windows.Forms If (-NOT $global:balloon) { $global:balloon = New-Object System.Windows.Forms.NotifyIcon [void](Register-ObjectEvent -InputObject $balloon -EventName MouseDoubleClick -SourceIdentifier IconClicked -Action { Write-Verbose 'Disposing of balloon' $global:balloon.dispose() Unregister-Event -SourceIdentifier IconClicked Remove-Job -Name IconClicked Remove-Variable -Name balloon -Scope Global }) } $path = Get-Process -id $pid | Select-Object -ExpandProperty Path $balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($SysTrayIconPath) $balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]$MessageType $balloon.BalloonTipText = $Message $balloon.BalloonTipTitle = $Title $balloon.Visible = $true $balloon.ShowBalloonTip($Duration) #Write-Verbose "Ending function" } Invoke-BalloonTip -Message "המחשב יינעל בעוד $messagesubseq שניות" -Title 'אזהרה!' -MessageType Warningתעתיק את זה לקובץ טקסט חדש, תשמור עם סיומת ps1 ותריץ. מה יוצא?
-
@שמח-לעזור אמר בשאלה | יצירת הודעה של WIN:
הוא נפתח לשניה אחת ונסגר בלי שום הודעה
לא הבנתי. איך אתה מריץ?
-
@שמח-לעזור אמר בשאלה | יצירת הודעה של WIN:
הוא נפתח לשניה אחת ונסגר בלי שום הודעה
לא הבנתי. איך אתה מריץ?
-
@שמח-לעזור לא.
תפתח פווארשל במיקום שהקובץ נמצא ואז תריץ את הקובץ מפווארשל ככה:.\filename.ps1ותעלה צילום של הפווארשל
-
@שמח-לעזור לא.
תפתח פווארשל במיקום שהקובץ נמצא ואז תריץ את הקובץ מפווארשל ככה:.\filename.ps1ותעלה צילום של הפווארשל
-
@שמח-לעזור תריץ את הפקודה הזו בפווארשל.
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachineעכשיו תנסה שוב להריץ כמו שכתבתי מקודם
-
@שמח-לעזור תריץ את הפקודה הזו בפווארשל.
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachineעכשיו תנסה שוב להריץ כמו שכתבתי מקודם
-
@שמח-לעזור לכתוב A ואנטר
-
@שמח-לעזור לכתוב A ואנטר
-
@שמח-לעזור אויש.. תריץ את פווארשל כמנהל כשאתה עושה את זה
-
@שמח-לעזור אויש.. תריץ את פווארשל כמנהל כשאתה עושה את זה



