Jump to content

How to delete Safely Remove Hardware and Eject Media tray icon in windows 10?


 Share

Recommended Posts

This worked in windows 7, but doesnt work in windows 10. Any way to delete Safely Remove Hardware and Eject Media tray icon in windows 10?

#NoTrayIcon
#RequireAdmin
#include <APIShellExConstants.au3>
#include <WinAPIShellEx.au3>

Global $tNOTIFYICONDATA = DllStructCreate($tagNOTIFYICONDATA)
DllStructSetData($tNOTIFYICONDATA, 'Size', DllStructGetSize($tNOTIFYICONDATA))
DllStructSetData($tNOTIFYICONDATA, 'Flags', $NIF_ICON)
DllStructSetData($tNOTIFYICONDATA, 'ID', 1226)
$systray = WinGetHandle("[Class:SystemTray_Main]")
DllStructSetData($tNOTIFYICONDATA, 'hWnd', $systray)
$result = _WinAPI_ShellNotifyIcon($NIM_DELETE, $tNOTIFYICONDATA)
If $result = 1 Then
   MsgBox(0,'','Icon removed.')
Else
   MsgBox(0,'','Icon not found.')
EndIf

 

Link to comment
Share on other sites

I thought changing the class to Shell_TrayWnd would work, but still doesn't.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

Was looking for a way to enumerate icon IDs in the systray...not having much luck, but I'd expect the ID is hard coded like 1226 is for Win 7 (unless I;m misinterpretting that values purpose).

Link to comment
Share on other sites

1 hour ago, spudw2k said:

Was looking for a way to enumerate icon IDs in the systray...

I found here script for that:

https://www.autoitscript.com/forum/topic/134538-get-systray-icons-solved/?do=findComment&comment=948301

I changed it a little to show ID instead of process name:

Systray Info.au3

Edited by Nikolas92
Link to comment
Share on other sites

Link to comment
Share on other sites

Im interested in this, but can't help further. Sry.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

It looks that this works.

; www.autoitscript.com/forum/topic/186068-how-to-delete-safely-remove-hardware-and-eject-media-tray-icon-in-windows-10/

#NoTrayIcon
#RequireAdmin
#include <APIShellExConstants.au3>
#include <WinAPIShellEx.au3>
#include <WinAPIProc.au3>
#include <WinAPI.au3>

Global $aAdjust, $hToken
Global $tNOTIFYICONDATA = DllStructCreate($tagNOTIFYICONDATA)
DllStructSetData($tNOTIFYICONDATA, 'Size', DllStructGetSize($tNOTIFYICONDATA))
DllStructSetData($tNOTIFYICONDATA, 'Flags', $NIF_ICON)
DllStructSetData($tNOTIFYICONDATA, 'ID', 1124)

$hToken = _WinAPI_OpenProcessToken(BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY))
_WinAPI_AdjustTokenPrivileges($hToken, $SE_DEBUG_NAME, $SE_PRIVILEGE_ENABLED, $aAdjust)
$aProcessList = ProcessList('RunDll32.exe')
For $i = 1 To $aProcessList[0][0]
   If _WinAPI_GetProcessCommandLine($aProcessList[$i][1]) = 'hotplug.dll,HotPlugSafeRemovalDriveNotification' Then ProcessClose($aProcessList[$i][1])
Next
_WinAPI_AdjustTokenPrivileges($hToken, $aAdjust, 0, $aAdjust)
_WinAPI_CloseHandle($hToken)

$iPid = Run('RunDll32.exe' & ' hotplug.dll,HotPlugSafeRemovalDriveNotification')
$Hotplug = ''
Do
   Sleep(10)
   $aData = _WinAPI_EnumProcessWindows($iPid, False)
   If @error = 0 Then
      For $x = 1 To $aData[0][0]
         If _WinAPI_GetClassName($aData[$x][0]) = 'HotPlugClass' Then
            $Hotplug = $aData[$x][0]
            ExitLoop
         EndIf
      Next
   EndIf
Until $Hotplug <> ''

DllStructSetData($tNOTIFYICONDATA, 'hWnd', $Hotplug)
$result = _WinAPI_ShellNotifyIcon($NIM_DELETE, $tNOTIFYICONDATA)
If $result = 1 Then
   MsgBox(0,'','Icon removed.')
Else
   MsgBox(0,'','Icon not found.')
EndIf
; www.autoitscript.com/forum/topic/186068-how-to-delete-safely-remove-hardware-and-eject-media-tray-icon-in-windows-10/

#NoTrayIcon
#RequireAdmin
#include <APIShellExConstants.au3>
#include <WinAPIShellEx.au3>
#include <WinAPIProc.au3>
#include <WinAPI.au3>

Opt("WinWaitDelay", 0)
Opt("MouseClickDelay", 0)
Opt("MouseClickDownDelay", 0)
Opt("MouseClickDragDelay", 0)
Opt("SendKeyDelay", 0)
Opt("SendKeyDownDelay", 0)
Opt("WinTitleMatchMode", 3)

Global $iPid
Global $result
Global $aAdjust, $hToken
Global $tNOTIFYICONDATA = DllStructCreate($tagNOTIFYICONDATA)
DllStructSetData($tNOTIFYICONDATA, 'Size', DllStructGetSize($tNOTIFYICONDATA))
DllStructSetData($tNOTIFYICONDATA, 'Flags', $NIF_ICON)
DllStructSetData($tNOTIFYICONDATA, 'ID', 1124)
_DeleteSafelyRemoveHardwareTrayIcon()
AdlibRegister('_CheckProcess')

While 1
   Sleep(1000)
WEnd

Func _CheckProcess()
   If not ProcessExists($iPid) Then _DeleteSafelyRemoveHardwareTrayIcon()
EndFunc

Func _DeleteSafelyRemoveHardwareTrayIcon()
   $hToken = _WinAPI_OpenProcessToken(BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY))
   _WinAPI_AdjustTokenPrivileges($hToken, $SE_DEBUG_NAME, $SE_PRIVILEGE_ENABLED, $aAdjust)
   $aProcessList = ProcessList('RunDll32.exe')
   For $i = 1 To $aProcessList[0][0]
      If _WinAPI_GetProcessCommandLine($aProcessList[$i][1]) = 'hotplug.dll,HotPlugSafeRemovalDriveNotification' Then ProcessClose($aProcessList[$i][1])
   Next
   _WinAPI_AdjustTokenPrivileges($hToken, $aAdjust, 0, $aAdjust)
   _WinAPI_CloseHandle($hToken)
   $iPid = Run('RunDll32.exe' & ' hotplug.dll,HotPlugSafeRemovalDriveNotification')
   $Hotplug = ''
   Do
      Sleep(10)
      $aData = _WinAPI_EnumProcessWindows($iPid, False)
      If @error = 0 Then
         For $x = 1 To $aData[0][0]
            If _WinAPI_GetClassName($aData[$x][0]) = 'HotPlugClass' Then
               $Hotplug = $aData[$x][0]
               ExitLoop
            EndIf
         Next
      EndIf
   Until $Hotplug <> ''
   DllStructSetData($tNOTIFYICONDATA, 'hWnd', $Hotplug)
   $result = _WinAPI_ShellNotifyIcon($NIM_DELETE, $tNOTIFYICONDATA)
   If $result = 1 Then
      MsgBox(0,'','Icon removed.')
   Else
      MsgBox(0,'','Icon not found.')
   EndIf
   Return $result
EndFunc

 

Edited by Nikolas92
Link to comment
Share on other sites

In my win 10 gave error of not able to find the hotplug module dll.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

  • 2 years later...

searched recently how to remove this icon, just adding it here since its not easy to find:

; forum.exetools.com/showthread.php?t=9378

#NoTrayIcon
#include <GUIConstants.au3>
#include <SendMessage.au3>

While 1
   $SystrayHandle = WinWait('[CLASS:SystemTray_Main]')
   _SendMessage($SystrayHandle, $WM_USER + 220, 2, 0)
   WinWaitClose($SystrayHandle)
WEnd

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...