This page is edited from the 1cmdfaq.txt faq-file contained in
my tscmd.zip
command line interface (CLI) collection. That zipped file has much
additional material, including a number of detached .cmd script
files. It is recommended that you also get the zipped version as a
companion.
Please see "
The Description and
the Index page" for the conditions of usage and other such
information.
168} How do I invoke Safely Remove Hardware using a cmd script?
Usually
the notification area
includes the following icon
However, that icon sometimes disappears. In that case safely to remove
hardware, and to get the icon back, you can use
@echo off & setlocal enableextensions
echo RunDll32.exe shell32.dll,Control_RunDLL hotplug.dll
:_ask
set ask_=
set /p ask_="Run this script to Safely Remove Hardware [N/y]?"
if /i "%ask_%"=="n" goto :EOF
if /i "%ask_%"=="" goto :EOF
if /i not "%ask_%"=="y" goto _ask
RunDll32.exe shell32.dll,Control_RunDLL hotplug.dll
endlocal & goto :EOF
An appropriate icon for the script is given by
Something like the following will pop up
On Windows 10