【问题标题】:How to show properly a balloontip?如何正确显示气球提示?
【发布时间】:2016-04-21 20:50:56
【问题描述】:

我正在为注册表中的( "vbs" ,"vbe" ,"wsf", "a3x") 等已知病毒键编写清理程序。

我想用这个脚本在powershell中添加一个BalloonTip,但是有问题!

我不知道如何从任务栏中删除图标以显示进度扫描?

这是草稿。尚未优化!

@echo off
Title Hackoo Virus Cleaner to delete virus key from registry by Hackoo 2016
Color 1A & Mode con cols=80 lines=8
Set Pattern="\.vbs"^
^ "\.vbe"^
^ "\.wsf"^
^ "\.a3x"^
^ "VBScript.Encode"^
^ "\winlogon\.bat"

Set Key="HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"^
^ "HKCU\Software\Microsoft\Windows\CurrentVersion\Run"^
^ "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"^
^ "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options"

For %%P in (%Pattern%) Do (
        For %%K in (%Key%) Do (     
            Cls 
            echo(
            echo(
            Echo         ***************************** Scan *****************************
            echo             %%K
            Echo         ****************************************************************
            Call :PS_Sub 'Warning' 10 '" Please wait... "' "' Scan is in progress.... %%K'" 'Warning'
            Call :Delete_Virus_Key %%K %%P "%TmpLogFile%"
        )
)
exit /b
::*************************************************************************
:Delete_Virus_Key <Key> <Pattern> <LogFile>
Setlocal enabledelayedexpansion
for /f "delims=REG_SZ" %%I in (
    'reg query "%~1" /s^|findstr /ic:"%~2"'
    )   Do  ( 
                If %ErrorLevel% NEQ 1 (
                    Set KeyName="%%~I"
                    (
                        Call:Trim !keyName!
                        Title Deleting Run key: !keyName!
                        echo Deleting Run key: !keyName!
                        echo reg delete "%~1" /v !keyName! /f
                        echo(
                        echo *****************************
                        echo reg delete "%~1" /v "!keyName!" /f
                        echo *****************************
                        echo(
                    )>>"%~3"
                    rem Call :PS_Sub 'Warning' 100 '"!KeyName!"' "'Delete !KeyName!'" 'Warning'
                ) else (
                    Set KeyName="%%~I"
                    Call:Trim !keyName!
                    Title Deleting Run key: !keyName!
                    echo Deleting Run key: !keyName!
                    echo reg delete "%~1" /v !keyName! /f
                    echo(
                    echo *****************************
                    echo reg delete "%~1" /v "!keyName!" /f
                    echo *****************************
                    echo(
                )>>"%~3"
            )       
)
EndLocal
Exit /b
::*************************************************************************
:Trim <String>
(
    echo Wscript.echo Trim("%~1"^)
)>"%tmp%\%~n0.vbs"
for /f "delims=" %%a in ('Cscript /nologo "%tmp%\%~n0.vbs"') do ( 
    set "KeyName=%%a" 
)
exit /b
::**************************************************************************
:PS_Sub $notifyicon $time $title $text $icon
PowerShell  ^
  [reflection.assembly]::loadwithpartialname('System.Windows.Forms') ^| Out-Null; ^
  [reflection.assembly]::loadwithpartialname('System.Drawing') ^| Out-Null; ^
  $notify = new-object system.windows.forms.notifyicon; ^
  $notify.icon = [System.Drawing.SystemIcons]::%1; ^
  $notify.visible = $true; ^
  $notify.showballoontip(%2,%3,%4,%5)
%End PowerShell%
exit /B
::*************************************************************************

所以为了简化我的问题,我们只关注这个函数:

我应该在此处添加什么来消除任务栏中的通知图标?

::**************************************************************************
:PS_Sub $notifyicon $time $title $text $icon
PowerShell  ^
  [reflection.assembly]::loadwithpartialname('System.Windows.Forms') ^| Out-Null; ^
  [reflection.assembly]::loadwithpartialname('System.Drawing') ^| Out-Null; ^
  $notify = new-object system.windows.forms.notifyicon; ^
  $notify.icon = [System.Drawing.SystemIcons]::%1; ^
  $notify.visible = $true; ^
  $notify.showballoontip(%2,%3,%4,%5)
%End PowerShell%
exit /B
::*************************************************************************

【问题讨论】:

  • 睡几秒后,$notify.Dispose()?我把气球提示弄乱了一点here,但从那以后我就睡了。
  • @rojo 是的,我认为它可以解决问题;)谢谢!

标签: powershell batch-file


【解决方案1】:

感谢@rojo 这样的想法,我解决了这个问题:

::**************************************************************************
:PS_Sub $notifyicon $time $title $text $icon $Timeout
PowerShell  ^
  [reflection.assembly]::loadwithpartialname('System.Windows.Forms') ^| Out-Null; ^
  [reflection.assembly]::loadwithpartialname('System.Drawing') ^| Out-Null; ^
  $notify = new-object system.windows.forms.notifyicon; ^
  $notify.icon = [System.Drawing.SystemIcons]::%1; ^
  $notify.visible = $true; ^
  $notify.showballoontip(%2,%3,%4,%5); ^
  Start-Sleep -s %6; ^
  $notify.Dispose()
%End PowerShell%
exit /B
::*************************************************************************

所以,如果有人想在 beta 版本中测试整个代码,这里是链接:

Hackoo Virus Cleaner

【讨论】:

  • OMFG 如何使用这种美感?另存为脚本并通过 PowerShell 打开?拜托,你介意告诉我看这个运行所需的步骤吗?感谢并祝贺您的​​工作! --------- 哦,对不起,它是一个 .bat - 已经运行了!非常非常棒。 - 它会说话!通知! Waaaaw ...你必须用所有这些Hackoo赚大钱!!!!!!!!!这种知识绝对是惊人的。
  • @statosdotcom LOL 我很高兴你喜欢它;)我最好的测试员!感谢您的支持和反馈!您是否尝试过此代码? stackoverflow.com/questions/38524510/…
猜你喜欢
  • 2011-01-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-09-15
相关资源
最近更新 更多