Support Forums

How to show properly a balloontip ?

Batch, ASP, JScript, Kixtart, etc.
Forum rules
Do not post any licensing information in this forum.
User avatar
hackoo
Posts: 103
Joined: Sat Jan 22, 2011 12:27 am

How to show properly a balloontip ?

Postby hackoo » Thu Apr 21, 2016 4:01 pm

I'm writing a cleaner for some known virus key like ( "vbs" ,"vbe" ,"wsf", "a3x", "VBScript.Encode" ) from the registry.

I want to add a BalloonTip in powershell with this script but, there is something wrong !

I don't know how to remove the icon from the taskbar to show the progress scan ?

This is a draft. It is not yet optimized !

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


So to simplify my issue, we focus just on this function :

What should i add here to get rid the notifyicon from the taskbar ?

::**************************************************************************
: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
::*************************************************************************
User avatar
jvierra
Posts: 10354
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: How to show properly a balloontip ?

Postby jvierra » Thu Apr 21, 2016 4:11 pm

When PowerShell exits the icon will be removed.
User avatar
hackoo
Posts: 103
Joined: Sat Jan 22, 2011 12:27 am

Re: How to show properly a balloontip ?

Postby hackoo » Thu Apr 21, 2016 4:22 pm

jvierra wrote:When PowerShell exits the icon will be removed.

I saw this http://stackoverflow.com/questions/2179 ... powershell
so how to add this method .Dispose() in my code ?
User avatar
jvierra
Posts: 10354
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: How to show properly a balloontip ?

Postby jvierra » Thu Apr 21, 2016 4:53 pm

When PowerShell exits the balloon tip will be disposed.
User avatar
jvierra
Posts: 10354
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: How to show properly a balloontip ?

Postby jvierra » Thu Apr 21, 2016 5:04 pm

If you are just looking to turn it on and off then just set the "Visible" property to false.
User avatar
jvierra
Posts: 10354
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: How to show properly a balloontip ?

Postby jvierra » Thu Apr 21, 2016 5:09 pm

Do the following at a prompt to see how it works:

.
Add-Type -Assembly System.Windows.Forms
$notify = new-object system.windows.forms.notifyicon
$notify.icon = [System.Drawing.SystemIcons]::Exclamation
$notify.visible = $true
 
# now just type the following
# $notify.visible = $false
User avatar
hackoo
Posts: 103
Joined: Sat Jan 22, 2011 12:27 am

Re: How to show properly a balloontip ?

Postby hackoo » Thu Apr 21, 2016 5:18 pm

I think i need to pause for a while and use the method .Dispose like that :

::**************************************************************************
: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); ^
Start-Sleep -s 5; ^
$notify.Dispose()
%End PowerShell%
exit /B
::*************************************************************************

So what do you think ?

Return to “Other Scripting Languages”

Who is online

Users browsing this forum: No registered users and 1 guest