<http://www.netikka.net/tsneti/info/tscmd168.htm>
Copyright © 2003-2010 by Prof. Timo Salmi  
Last modified Wed 5-May-2010 07:44:34

 
Assorted NT/2000/XP/.. CMD.EXE Script Tricks
From the html version of the tscmd.zip 1cmdfaq.txt file
To the Description and the Index
 

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

Similar references/comments:
  Safely Remove Hardware Icon not in Taskbar when flashdrive is plugged in