Nikolas92

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

11 posts in this topic

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

 

Share this post


Link to post
Share on other sites



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


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

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

BeatsPlayer - Music player.

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

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.

Firefox Profile Backup - Backup/restore previously saved profile.

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

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

 

Share this post


Link to post
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).

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

id is same (1226), but for Module instead of stobject.dll (on windows 7) it shows explorer.exe on windows 10

10.jpg

7.jpg

Edited by Nikolas92

Share this post


Link to post
Share on other sites

Any way to delete Safely Remove Hardware and Eject Media tray icon in windows 10 or not?

Share this post


Link to post
Share on other sites

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


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

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

BeatsPlayer - Music player.

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

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.

Firefox Profile Backup - Backup/restore previously saved profile.

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

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

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

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


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

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

BeatsPlayer - Music player.

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

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.

Firefox Profile Backup - Backup/restore previously saved profile.

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

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

 

Share this post


Link to post
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