2016-04-21 13 views
5

Sto scrivendo un pulitore per alcuni virus noti come ("vbs" ,"vbe" ,"wsf", "a3x") dal registro.Come mostrare correttamente un balloontip?

Vorrei aggiungere un BalloonTip in PowerShell con questo script ma, c'è qualcosa di sbagliato!

Non so come rimuovere l'icona dalla barra delle applicazioni per mostrare la scansione di avanzamento?

Questa è una bozza. Non è ancora ottimizzato!

@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 
::************************************************************************* 

Così per semplificare il mio problema, ci concentriamo solo su questa funzione:

cosa devo aggiungere qui per ottenere liberare il NotifyIcon dalla barra delle applicazioni?

::************************************************************************** 
: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 
::************************************************************************* 
+2

Dopo aver dormito qualche secondo, '$ notificare .Dispose() '? Ho incasinato un po 'di suggerimenti sui palloncini [qui] (http://stackoverflow.com/a/30484358/1683264), ma da allora ho dormito. – rojo

+2

@rojo Sì, penso che possa fare il trucco;) Grazie! – Hackoo

risposta

2

ho risolto il problema grazie alla @rojo idea in questo modo:

::************************************************************************** 
: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 
::************************************************************************* 

Quindi, se qualcuno come per testare l'intero codice in versione beta, ecco il link:

Hackoo Virus Cleaner

enter image description here

+1

OMFG come uso questa bellezza? Salva come script e aperto da PowerShell? Per favore, ti dispiacerebbe mostrarmi i passi che ho bisogno per vedere questo correre? Grazie e congratulazioni per il tuo lavoro! --------- oooh, mi dispiace, è un .bat - l'ho già fatto! Molto molto carino. - Parla! Notifica! Waaaaw ... Devi fare un sacco di soldi con tutto questo Hackoo !!!!!!!!! Questa conoscenza è assolutamente incredibile. – statosdotcom

+1

@statosdotcom LOL sono contento che tu lo ami;) il mio miglior tester! Grazie per il vostro supporto e per il vostro feedback! Hai provato questo codice o no? http://stackoverflow.com/questions/38524510/open-a-file-through-cmd-and-display-the-selected-in-specific-editor/38525929#38525929 – Hackoo