|
Licence |
All tools on this page work under Windows 2000 and higher. They are Freeware.
Allowed:
- usage in any environment, including commercial
- include in software products, including commercial
- include on CD/DVD of computer magazines
Not allowed:
- modify any of the files
- offer for download by means of a "downloader" software
I don't ask for donations but some users insist, so:
PayPal
|
|
|
|
|
RemoveDrive V3.4.3 - Safe removal of drives |
RemoveDrive prepares drives for "Safe Removal" by commandline. It works with drives only. For other device types there is DevEject by Matthias Withopf.
RemoveDrive DriveSpec: [-v][-d][-l][-t][-f][-vhd][-h][-a][-b][-i][-s][-w:nnnn][-na]
DriveSpec is the drive to remove, e.g. U: or an NTFS mountpoint as
"C:\CardReader\Multi Reader SD"
or . for the current drive
or \ for the drive of the RemoveDrive.exe
or a volume name like \\?\Volume{433619ed-c6ea-11d9-a3b2-806d6172696f}
or a kernel name like \Device\HarddiskVolume2 (Volume)
or a kernel name like \Device\Harddisk2\DR0 (Disk)
or a partition name like \Device\Harddisk2\Partition1
or a device ID
or a friendly name like 'Corsair Voyager'
or a volume label like 'Backup01'
Wildcards can be used.
-47 perform safe removal resulting in problem code 47
-v remove the volume only instead of the drive or whole device
-d remove the drive only instead of the whole device
-L loop until success
-f force the safe removal (needs admin previleges)
-t release TrueCrypt and VeraCrypt volumes hosted by the drive to remove
-vhd detach VHD/VHDX/ISO (Win7+) if the the removed drive is VHD hosted
-h show open handles
-h:X show open handles on a different drive (e.g. a TrueCrypt
volume whose container is on the drive to remove, not required
if -t -h is used)
-a activates Windows of applications owning the open handles, requires -h
-w:nnnn wait nnnn milliseconds before closing the program (time to read its output)
-s self delete removedrive.exe
-b show the "Safe To Remove Hardware" balloon tip
(up to Windows 7 shown by Windows, from Windows 8 by RemoveDrive)
-i stop Windows indexing service (XP: CiSvc, Vista+: WSearch) for a moment if required (admins)
-na no about info
-dbg show debug information
Caution: With V2.4 the parmeter for showing debug information changed to -dbg. -d is now for removing the drive only instead the whole device.
RemoveDrive can be used with all types of drives. Started with -L it tries to remove the drive in an endless loop until success or until canceled.
As result it shows 'success' in green or 'failed' in red.
The commandline options are case insensitive, I use the upper case L here to prevent confusions with the digit 1.
Sample:
removedrive u: -L
would try to prepare drive U: for safe removal in an endless loop until success.
For drives mounted into NTFS folders the full or relative path of the folder can be used:
removedrive "E:\_CardReader\USB20 CF" -L
Used with multislot-cardreaders it would remove the whole reader, regardless of the given slot. For removing a card only, use my EjectMedia tool, see below.
Instead the drive letter one of the drive's device ID strings can be used. The friendly name can be used as "SanDisk Extreme" or the hardware ID of the USB device, like USB\VID_1234&PID_5678...
Wildcards can be used here. E.g. RemoveDrive *Flash* to remove the first drive with 'Flash' in its device name.
For drives without a mountpoint any ID string or the device's "friendly name" (also using wildcards) can be used:
removedrive "Sandisk Extreme" -L
removedrive "USBSTOR\DISK&VEN_SANDISK&PROD_EXTREME*" -L
removedrive "USB\VID_0781&PID_5580\*" -L
If started with admin privileges or the USBDLM command interface available,
then a removed USB drive ends up with problem code 21 and can be reactivated
by means of RestartSrDev or UsbDriveInfo.
Without admin privileges or with parameter -47 the device gets code 47 and cannot be reactivated alone by means of the device management,
instead its parent device (e.g. a USB hub) must be reactivated or its USB port resetted by means or UsbDriveInfo, UsbTreeView or RestartUsbPort.
With some 3rd party USB3 drivers the USB device completely disappears after safe
removal instead staying present with a problem code.
Here you can use the parameter -d to remove the drive only which then stays with a problem code.
RemoveDrive can be started from the drive to remove. Because a running EXE on a drive prevents a drive being prepared for safe removal
it creates a temporary, self deleting copy and starts it with the same parameters. The returned errorlevel is 4 then.
To be drive letter independent, use . instead a drive letter. The current drive is removed then.
To remove the drive of the RemoveDrive.exe use \ as drive.
If the removal fails then someone still accesses the drive. This can be something obvious like an open Word document or a mounted TrueCrypt container or some kind of monitoring tool like a virus scanner. A network share on the drive that has been used makes the removal fail too.
Started with parameter -h RemoveDrive tries to show open handles on the drive to remove and with -a it activates windows of processes which hold open handles.
But it doesn't always find all handles. By means of the SysInternals
ProcessExplorer you might be able to find more. After starting it go to 'Find' -> 'Find Handle or DLL', enter the drive letter like X:\ or a part of the kernel-name like 'Harddisk3' and search.
When started with parameter -L and the removal failed then the E key can
be pressed to perform a media eject after locking and dismounting the volume.
It depends on the device if ejecting the media is supported or not. But the
important part is to lock and dismount the volume. If locking succeeds the there where no
open handles on the volume. If locking fails then dismounting can be forced
by pressing the F key. Then at least the file system is dismounted and in a
consistent state, the device can be removed "safely enough".
Since V3.3 the safe removal can be forced, either by giving parameter -f or -l and pressing the F key when asked for.
The author of HotSwap!, Kazuyuki Nakayama told me how:
Setting the "Offline" attribute for the disk devices removes all the disk's volumes and stops all handles to the volumes
blocking the safe removal. This function is supported since Windows Vista.
Download latest release: removedrive.zip
V2.5 for Windows 2000: removedrive2500.zip
Last update: 07 Feb 2024
For programmers I've made a demo project which shows the essentials:
How to prepare a USB drive for safe removal
A free alternative to the Windows tray icon is "HotSwap!":
http://mt-naka.com/hotswap/index_enu.htm
|
|
|
|
|
RestartSrDev V3.1 - restarts "Safely Removed" devices which have the "Code 21" or "Code 47" problem code |
Usage:
RestartSrDev DeviceId [-f][-t][-w:nnnn][-na]
DeviceId: is the device's device instance ID, it can include wildcards,
enclose it by doublequotes if it contains the & char
-f force the restart of the parent device if there are other devices attached
-t test only
-w:nnnn wait nnnn milliseconds before end the program (time to read its output)
-na no about info
-d debug info (show all devices)
Samples:
RestartSrDev *
RestartSrDev USB\VID_0781*PID_5406*
RestartSrDev "USB\VID_0781&PID_5406\0000051017037750"
RestartSrDev "Sandisk Extreme"
If the & char is used in a parameter then the whole parameter must be enclosed by quotation marks. Otherwise the & char splits the command line into two seperate ones which will not work.
Admin rights are required (or an active USBDLM command interface).
Returns Errorlevels:
0 - successfully restarted at least one device
1 - no device restarted
2 - other problem
Background information
After using the Windows "Safely Remove Hardware" facility,
a device gets the
problem code 47, which is a constant from the cfg.h:
CM_PROB_HELD_FOR_EJECT.
As far as known, a device with this problem code cannot be
reactivated. The only way for a USB device is to restart
the hub which this device is attached to. This can be a
root hub or a standard hub. But of course this will restart all
devices attached to this hub. Therefore RestartSrDev performs the restart
of the parent devices only if the device to reactivation is the only one
attached there or the parmeter -f (force) is set.
But sometimes devices have problem code 21 after the safe removal, which is
CM_PROB_WILL_BE_REMOVED.
Devices with this problem code can be reactivated by restarting them. This can be done by means of the Microsoft DEVCON tool (DEVCON restart DeviceInstanceID). My tool restarts only devices with the problem code 21 or 47, so usually you can just start it with a asterisk as paramerter to restart all devices with code 21.
It seems that it depends on the API call which is used to perform the safe removal. There are two:
CM_Query_And_Remove_SubTree and CM_Request_Device_Eject.
CM_Query_And_Remove_SubTree leads to "Code 21" while CM_Request_Device_Eject leads to "Code 47".
Obviousely the removal is not complete with Code 21, but since drive and volume are gone then it should be "safe" enough.
CM_Query_And_Remove_SubTree requires admin privileges while CM_Request_Device_Eject works for restricted users
too.
The Windows Safe Removal leads to Code 47, so probably it uses CM_Request_Device_Eject.
My tool RemoveDrive tries CM_Query_And_Remove_SubTree
first and if this fails then it tries CM_Request_Device_Eject.
So, if you have admin privileges (or a USBDLM V4.8 with activated command interface) and removing a drive by means of RemoveDrive, then it is possible to reactivate the drive by means of RestartSrDev.
Code 47 devices can be reactivated by restarting their parent device (e.g. a USB hub) or (since V3.0) by restarting the device's USB port,
which works under XP, Windows 8, 10 and 11 with the Microsoft standard USB drivers.
Download: RestartSrDev.zip
Last update: 24 Oct 2023
|
|
|
|
|
EjectMedia V3.2.1 - ejects a media from a drive |
It ejects a media from a drive rather that removing the whole device by commandline. Ejecting the media only is especially suitable for internal cardreaders.
On CD/DVD and ZIP drives the media is physically ejected while on flash cardreaders the media is ejected logically only. It cannot being accessed before it's removed and inserted again.
Windows passes the eject request down to the drive even it is a fixed drive. Most fixed drives answer "invalid function" but some respond success and "no media" afterwards.
Under XP this is not allowed for restricted users but this can be enabled by a policy.
EjectMedia DriveSpec [-L][-d][-f][-h][-w:nnnn][-na]
DriveSpec is the drive whose media to eject, e.g. U: or an NTFS mountpoint
as "C:\CardReader\Multi Reader SD"
or . for the current drive
or \ for the drive of the EjectMedia.exe
or a volume name like \\?\Volume{433619ed-c6ea-11d9-a3b2-806d6172696f}
-t release TrueCrypt volumes hosted on the drive to eject
-L loop until success
-d dismount only (do not eject)
-f force dismount or eject
-o take volume offline
-h show open handles
-a activate windows of processes which hold open handles
-na no about info
-w:nnnn wait nnnn milliseconds before end the program (time to read its output)
As RemoveDrive, EjectMedia can be started from the drive to remove.
Download: ejectmedia.zip
Last update: 21 April 2020
For programmers I've made a demo project which shows the essentials:
How to flush a storage volume's file cache, lock and dismount it, and eject the media
|
|
|
|
|
LoadMedia V1.5 - Loads a media or brings a volume online |
LoadMedia is the counterpart of EjectMedia - it loads CD/DVD media by closing the tray or brings an
offline volume online.
But loading a media has a physical effect on CD/DVD drives with a tray only. ZIP drives have no mechanic for loading a media.
An ejected card of a cardreader or USB flash drive might be reactivated or not, it depends on the device.
LoadMedia drive [-d][-f][-w:nnnn]
DriveSpec is the drive whose media to load, e.g. U: or an NTFS mountpoint as "C:\CD-Drives\Burner1"
or . for the current drive
or \ for the drive of the LoadMedia.exe
or a volume name like \\?\Volume{433619ed-c6ea-11d9-a3b2-806d6172696f}
-f force load of the volume appears to be already loaded and online
-na no about info
-w:nnnn wait nnnn milliseconds before end the program (time to read its output)
Download: loadmedia.zip
Last update: 4 Jan 2018
|
|
|
|
|
EjectTcv V3.2.0 - 'ejects' a TrueCrypt or VeraCrypt Volume |
EjectTcv (EjectTrueCryptVolume) is a commandline tool which 'ejects' a TrueCrypt volume. Since V2.7 it works with VeraCrypt too.
Ejecting with VeraCrypt since V1.18 works since EjectTcv V2.8.4.
Advantages over original TrueCrypt tool:
- can identify the TrueCrypt volume by its container
- can loop until success and offers forcing the ejection by pressing F
- can show open handles
- does (in contrast to VeraCrypt) not wake up sleeping drives
I used the term 'eject' because under Windows the term 'dismount' (as used by the original tool) means only
to disconnect the file system but
keeping the volume present. If you object that this is the case for eject too then you are right. Remove or release would have been
better terms.
EjectTcv DriveSpec [-L][-f][-h][-na][-w:nnnn]
DriveSpec is something that defines the TrueCrpyt Volume to eject,
e.g. T: (the TrueCrypt volume's drive spec)
or its VolumeName like Volume{GUID}
or the path of its container, e.g. a partition name or a file name
-l loop until success
-f force
-h show open handles
-a activates Windows of applications owning the open handles, requires -h
-na no about info
-w:nnnn wait nnnn milliseconds before end the program (time to read its output)
It can be started from the volume to eject, it creates a temporary copy then.
It must be called from the same user context ('normal' and 'as administrator')
as the volume has been mounted, otherwise VeraCrypt does not delete the drive
letter in the other context!
Samples:
EjectTcv T:
EjectTcv T: -L -h
EjectTcv \Device\Harddisk1\Partition1
EjectTcv C:\secret.tc
Returns errorlevels:
0 - success
1 - success by force
2 - TC volume gone while trying
3 - TC volume not removed
4 - 2nd instance started
5 - invalid params
Download: ejecttcv.zip
Last update: 8 March 2018
|
|
|
|
|
ReMount V2.3.1 - reassigning mountpoints (change drive letters) |
Using ReMount you can quickly change a drive letter without clicking thru the Windows disk management. E.g. to change drive F: to U:
remount f: u:
If both letters are in use and shall be swapped then use parameter -s
remount f: u: -s
For nonsense operations, as remonting the Windows system drive or mounting a local drive to a letter used by a network drive, use parameter -f (force). Furthermore -f can be used to remount a drive to a drive letter which is in use. The drive which uses the target letter is remounted to the first free letter.
remount c: x: -f
Instead of drive letters you can use NTFS mount points too.
Admin privileges are required.
A graphical alternative for quickly changing mount points is UsbDriveInfo, started with admin
privileges you can right-click a volume and select "Drive Letter". The tool shows Non-USB drives too if this is activated in
the Options menu.
Download: remount.zip
Last update: 07 Feb 2024
|
|
|
|
|
FFB - Flush File Buffers |
FFB is a commandline tool which flushes the write cache of one or more storage volumes. It is similar
to the Unix sync command or the
Sysinternals Sync tool.
The name comes from the Win32 API call FlushFileBuffers:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa364439(v=vs.85).aspx
The Sysinternals sync tool can flush volumes only which have
a drive letter. And it forgets drive Z: when called without
parameters.
Sleeping drives are skipped unless -f is given. VHD, TrueCrpyt and VeraCrypt volumes are resolved to their
physical drives to check for being at sleep, other file hosted volumes are not, so unwanted disk wakeups
might happen.
Usage:
FFB [VolumeSpec1] [VolumeSpec2] ... [VolumeSpecN] [-p] [-d] [-f]
VolumeSpec can be a drive letter, a drive or any kind of mountpoint
-p purge the file cache
-d dismount the volume(s) if possible
-f force dismount (open handles become invalid); or force flush of sleeping drives
Samples:
FFB C
FFB C D E
FFB C: D: E:
FFB C:\ D:\ E:\
FFB C:\CardReader\SD
FFB \\?\Volume{16b5dd59-158f-11e1-b349-00166f0dc865}
FFB \\?\Volume{16b5dd59-158f-11e1-b349-00166f0dc865}\
FFB X: -d -f
Flushing and purging a volume's cache requires admin privileges, so, restricted users cannot do that.
To overcome this limitation I have given the "USB Drive Letter Manager (USBDLM)" V4.8 a command
interface which FFB can use for flushing the file cache.
See USBDLM help in section "Settings" for details.
Download: FFB.zip
Last update: 03 Oct 2021
|
|
|
|
|
AttachVHD V1.0.2 - attaches VHDs by command line |
Windows 7 and higher have build-in VHD support, XP, Server 2003, Vista, Server 2008 need
Microsoft Virtual Server 2005 installed in its default folder (%ProgramFiles%\Microsoft Virtual Server\Vhdmount), here AttachVHD
looks for its vhdmount.dll.
Since Windows 10 it works with ISO files too.
Admin previlegs are required or (under Windows 7 and higher) USBDLM V5.4.6+ with CommandInterface 0x100 active.
The posibility to attach a VHD without admin previleges was the reason to create this tool, otherwise there are
Windows diskpart, powershell and vMount: http://reboot.pro/files/file/477-vmount
Usage:
AttachVHD VHDfile [-n][-w:nnnn]
VHDfile: the VHD/VHDX/ISO file
[-n] no wait before close
[-w:nnnn] wait nnnn milliseconds before close
Sample:
AttachVHD X:\test.vhd
Download: AttachVHD.zip
Last update: 03 Oct 2021
|
|
|
|
|
DriveCleanup V1.6.5 - remove nonpresent drives from the registry |
DriveCleanup is a command line tool which does what you could do manually in the
Windows Device Manager or my means of DeviceCleanup, it removes all
currently non-present USB Storage Devices, Disks, CDROMs, Floppies, Storage Volumes and WPD devices from the device
tree. Furthermore it removes orphaned registry items related to these device types:
- HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices
- HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum
- HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\UsbFlags
- HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\DeviceClasses
- HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2
- HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\CPC\Volume
- HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\CPC\LocalMOF
- HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\BitBucket\Volume
Started with parameter -t (like test) it shows which devices and registry keys and values it would remove.
DriveCleanup -t
Started with admin privileges and without a parameter it does its job without further inquiry.
To remove certain types of devices there are the parameters -U -D -C -F -V -W and -R, see DeviceCleanup.txt.
Sample to remove abandoned registry entries only:
drivecleanup -r
Under x64 editions of Windows only the included x64 version works.
Admin privileges are required for actual cleanup, without it requests to switch into the test mode.
Since V1.0 it removes non-USB drives if they have a removal policy > 1 (EXPECT_ORDERLY_REMOVAL or EXPECT_SURPRISE_REMOVAL).
When started standalone it waits for a keystroke at the end. This can be skipped by param -n or by starting it minimized or hidden.
Download:
DriveCleanup.zip
Last update: Feb 2024
A related tool is DeviceCleanup.
|
|
|
|
|
VerifyDisk V1.0.2 - a command-line tool to call IOCTL_DISK_VERIFY |
Usage:
VerifyDisk [disknumber][-ld | -r | -r2]
disknumber a disk's number as shown in the disk management or by -ld
-r read instead of IOCTL_DISK_VERIFY
-r2 read twice and compare instead of IOCTL_DISK_VERIFY
-ld list disks
Samples:
VerifyDisk -ld
VerifyDisk 0
VerifyDisk 0 -r
By default VerifyDisk calls IOCTL_DISK_VERIFY over a whole disk device.
Even available since Windows NT 3.1 back in 1993, all Microsoft says about IOCTL_DISK_VERIFY
ever since is "Verifies the specified extent on a fixed disk":
https://learn.microsoft.com/en-us/windows/win32/api/winioctl/ni-winioctl-ioctl_disk_verify
Probably it sends one of the SCSI VERIFY commands to the disk device.
Which effect is has seems to depend on the device:
Classic hard-drives deliver the same speed on verify as on read.
Some SSDs are slow on first verify and fast on futher attempts, so they obviously do
something. They deliver less speed on verfiy than on read which is another sign that
they actually perform a verification.
But there are other SSDs which deliver insane high speeds on verify (> 10 times faster
than read) which might indicate that they ignore the request and do nothing.
USB adaptors might no pass the command to the disk, resulting either in
ERROR_INVALID_FUNCTION or insane speed if they just return it as successful.
Read tests require admin privileges.
For "reading twice and compare" VerifyDisk tries to lock and dismount all volumes on
this disk to prevent concurrent write accesses which might lead to false alerts.
Download:
VerifyDisk_Win32.zip
VerifyDisk_x64.zip
Last update: April 2024
|
|
|
|
|
ListDosDevices |
Drive letters are references to kernel objects thru 'symbolic links'. For historical reasons they are sometimes called 'DOS device names'.
ListDosDevices shows which kernel-name is behind each drive letter.
Sample:
A: REMOVABLE \Device\Floppy0
B: ----
C: FIXED \Device\HarddiskVolume1
D: FIXED \Device\HarddiskVolume2
E: CDROM \Device\CdRom0
F: CDROM \Device\CdRom1
G: ----
H: ----
I: CDROM \Device\IsoCdRom0
J: ----
K: ----
L: ----
M: ----
N: ----
O: ----
P: REMOTE \Device\LanmanRedirector\;P:0000000000013548\server01\public
Q: REMOTE \Device\NetWareRedirector\WFS1\SERVER02\PUBLIC
R: ----
S: FIXED \??\C:\Dokuments and Settings\Uwe\Application Data
T: ----
U: REMOVABLE \Device\Harddisk5\DP(1)0-0+19
V: FIXED \Device\VeraCryptVolumeV
W: ----
X: CDROM \Device\WMDisk0
Y: FIXED \Device\TrueCryptVolumeY
Z: ----
Here are
A: Floppy
C: + D: partitions of a fixed drive
E: + F: CD or DVD drives
I: Virtual CDROM created by UltraISO
P: Windows Network drive
Q: Novel Network drive
S: Subst drive
U: USB flash drive (Win2000, XP, 2003; Since Vista the kernel-name looks like a partition.)
V: VeraCrypt volume
X: Virtual drive created by WinMount
Y: TrueCrypt volume
Download: listdosdevices.zip
|
|
|
|
|
DeleteDosDevice |
When a software crashes which had created virtual drives under a drive letter, then it leaves a dead drive letter behind.
Started again the software in question might be able to fix this but somtimes it just sees a drive letter in use.
In such cases you can try to remove the dead drive letter by means of DeleteDosDevice.
Sometimes the tool reports success because Windows sayed so, but the drive drive letter persists :-(
Sample for removing X:
deletedosdevice x:
Since V0.4 in can delete any type of DOS-device, e.g. a serial port as "COM10".
Download V0.4: deletedosdevice.zip
Last update: 19 Feb 2012
|
|
|
|
|
RescanDevices |
When an IDE or SATA drive has been prepared for safe removal it can be reactivated by a scan for new hardware.
That's what this tool initiates.
It is a non interactive, invisible Windows application. It does the same as Microsoft's tool DEVCON when called with
parameter 'rescan', but no console window pops up.
Download: rescandevices.zip
|
|
|
|
|
XP SystemRestore Enable/Disable |
Enabling or Disabling XP SystemRestore for one or more drives.
Sample: Disable SystemRestore on drive D:
srd d:
Sample: Disable SystemRestore on drives D: to Z:
srd d-z
SRE enables the XP SystemRestore on certain drives.
If the SystemRestore is enabled or disabled for the system drive then this is done of all other local drives too!
This tool is for XP only. W2K has no system restore and since Vista the SystemRestore deals with the system drive only.
Download: systemrestore.zip
|
|
|
|
|
AutoRun Settings V1.4 |
AutoRunSettings gives easy access to the basic Windows AutoRun settings.
AutoRun can be disabled depending on the drive type and depending on the drive letter
by Explorer Policies.
These values are
- NoDriveAutoRun
and
- NoDriveTypeAutoRun
under
SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer
See here:
NoDriveAutoRun
http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/regentry/58886.mspx
By default (the value doesn't exist) AutoRun is enabled for all drive letters.
NoDriveTypeAutoRun
http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/regentry/93502.mspx
They are valid under HKEY_LOCAL_MACHINE and under HKEY_CURRENT_USER. If a value exist
under HKEY_LOCAL_MACHINE then the same value under HKEY_CURRENT_USER is ignored.
Microsoft TweakUI sets the values under HKEY_CURRENT_USER only and completely ignores
HKEY_LOCAL_MACHINE. Furthermore TweakUI cannot make settings for hard drives and it
enables AutoRun for network drives by completly ignoring the default values.
For AutoRun and AutoPlay to work the service "Shell Hardware Detection" (ShellHWDetection) is required. If AutoRun is deactivated
by the above settings then keeping this service running is in vain under XP unless autoruns for non drive devices are required.
Under Vista and Windows 7/8/10 the WIA service relies on it.
These settings have effect only for the moment when a drive is attached. They do not deactivate AutoRun when the drive is opened
manually in the Windows Explorer. This is changend with the Microsoft XP Patch KB950582, availlable since August 2008, see here:
http://support.microsoft.com/kb/953252
Since end of February 2009 it is automatically distributed as KB967715...
An alternative is to completely disable the autorun.inf mechanisms as
suggested by the US-CERT. This prevents the Windows behaviour
beeing changed by an autorun.inf file but the selection dialog is still working.
Another setting for CDROM drives is the value "AutoRun" under HKLM\SYSTEM\CurrentControlSet\Services\Cdrom. Despite the name
it controls the 'Auto Insert Notification', also called 'Media Change Notification (MCN)'. When deactivated media changes are
not detected, therefore AutoRun does not work. But this is a side effect only. This should stay activated. Microsoft says
"Do not disable the MCN message unless you have no alternative". One reason to deactivate this is a cyclic flashing HDD-LED
which happens on some computers with MCN enabled.
For changing system global settings administrator privileges are required. So under Vista and Windows 7/8/10 you have to right
click AutoRunSettings in the Explorer and select "Start as administrator" or create a link to it with this setting.
Screenshot (AutoRun completely deactivated):
Screenshot XP defaults
Download: autorunsettings.zip
Last update: Dec 2010
|
|
|
|
|
USB-WriteCache V0.2 |
My means of USB-WriteCache you can force the activation of a write-cache for USB disk devices.
It reads/writes the registry values WriteCacheEnableOverride and UserRemovalPolicy under HKLM\SYSTEM\CurrentControlSet\Enum\<DeviceInstanceID>\Device Parameters\Classpnp.
They are read and written by means of the DeviceIoControl calls IOCTL_STORAGE_GET_HOTPLUG_INFO and
IOCTL_STORAGE_SET_HOTPLUG_INFO.
For making a setting it needs admin privileges, otherwise you get an "Access is denied" error.
New settings take effect after the drive is restarted or re-attached or the system is restarted.
The used STORAGE_HOTPLUG_INFO data struct has four members that can be read:
typedef struct _STORAGE_HOTPLUG_INFO {
DWORD Size;
BOOLEAN MediaRemovable;
BOOLEAN MediaHotplug;
BOOLEAN DeviceHotplug;
BOOLEAN WriteCacheEnableOverride;
} STORAGE_HOTPLUG_INFO, *PSTORAGE_HOTPLUG_INFO;
Only DeviceHotplug and WriteCacheEnableOverride can be set, see here:
https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-storage_hotplug_info
Yes, they say "don't use WriteCacheEnableOverride", but it works anyway...
While WriteCacheEnableOverride goes 1:1 to the registry value of the same name things are more
complicatied with DeviceHotplug:
DeviceHotplug = FALSE -> UserRemovalPolicy = 2 (CM_REMOVAL_POLICY_EXPECT_ORDERLY_REMOVAL) aka "Better performance"
DeviceHotplug = TRUE -> UserRemovalPolicy = 3 (CM_REMOVAL_POLICY_EXPECT_SURPRISE_REMOVAL) aka "Quick removal"
With DeviceHotplug OFF and WriteCacheEnableOverride ON you get the most write cache.
With DeviceHotplug ON and WriteCacheEnableOverride OFF you get almost no write cache under Win8/10.
Screenshot:
Download: usb-writecache.zip
Last update: 15 Aug 2021
|
|
|
|
|
MaximumTransferLength since Windows 7 SP1 |
Since Windows 7 SP1 the block size of USB data transfers of USBSTOR drives can be changed for each device from the default of 64 KB. A larger transfer length reduces protocol overhead and therefore increases the transfer speed.
The setting was introduces in 2011 with a Hotfix
2581464. Today an updated Windows 7 SP1 is good enough - no need for the hotfix. Of course it works too under Windows 8..11
The setting is made in the registry on a per USB device base: Under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbstor there are already some keys for devices which need special treatment as Apple iPods (05AC12xx and 05AC13xx). The keys are made of eight hex digits, four for the USB vendor ID and four for the product ID. Even not documented the key obviously supports the x character as a wildcard. The factory keys consist an undocumented value DeviceHackFlags which gives these devices a special treatment.
By means of a DWORD value named MaximumTransferLength the block size of data transfers can be increased:
Default are 64 KB, maximum value 2 MB.
Some devices cannot handle larger blocks and some older USB hubs seem to cause problems too.
Therefore 64 KB are still default, even under Windows 8..11.
After changing the value the device must be re-attached or restarted. I've made a little tool for this, it can perform a read speed test, make the setting and restart the device. It must be started "As Administrator":
The Hotfix documentation states that the value must be "between 65535 (64 KB) and 2097120 (2 MB)". But these values are unusual
for a data transfer buffer, here multiples of a physical page (4096) make sense and indeed I got an instant blue screen when
using 2 × 65535 = 131070. Therefore the tool uses 65536 (64 KiB) to 2097152 (2 MiB).
Newer USB drives use the USB Attached SCSI protocol (UASPStor) which has less protocol overhead and uses a larger transfer
length offhand (512KB), so tuning is needed for USBSTOR devices only. If you want to play:
The MaximumTransferLength value for UASPStor devices is under HKLM\SYSTEM\CurrentControlSet\Enum\USB\VID_xxxx&PID_xxxx\Device Parameters.
Download: UsbStorMaxTransferLen.zip
Last update 03 Oct 2021
| |
|
|
|
Misc |
To work effective on the Windows Console I suggest FAR - the
File and Archive Manager. It's a Norton Commander clone for the Win32 Console.
And my Console fonts to get an authentic DOS look :-)
|
|
|
|
Uwe Sieber
Home: https://www.uwe-sieber.de/english.html
|