Tools for Windows

  German version of this page
All tools on this page work under Windows 2000 and higher. They are Freeware.

- 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:


  USB Device Tree Viewer
Got it's own page: UsbTreeView



  RestartUsbPort V1.2.1 - Restarts a USB port

RestartUsbPort performs a USB port restart by commandline. You can try first in the GUI application USB Device Tree Viewer by right-clicking a device and select "Restart Port" to see if it is useful.
In contrast to a device restart thru the device manager, the device's driver stack is not asked for permission, so it always works. It is more like re-plugging the USB device.
RestartUsbPort [PortId] [-u] [-l] [-na] [-d:nnnn] [-w:nnnn]
PortId can be
 a device instance ID (in quotation marks because it contains the & char)
 a driver key name
 a device location info
 a friendly device name (in quotation marks if it contains space or &)
 a port chain in UsbTreeView style
-u      uninstall USB device before port reset
-l      lists USB ports that can be restarted
-na     no about info
-n      no wait for keypress when started standalone
-w:nnnn waits nnnn milliseconds on end
-d:nnnn delays nnnn milliseconds on start

RestartUsbPort -l

RestartUsbPort "USB\VID_0781&PID_5580\AA010319131128161470"

RestartUsbPort {36fc9e60-c465-11cf-8056-444553540000}\0007

RestartUsbPort Port_#0002.Hub_#0008

RestartUsbPort "Sandisk Extreme"

RestartUsbPort 1-4-2

RestartUsbPort 1-4-2 -u

RestartUsbPort 1-4-2 -w:1000
If the & char is used in a parameter then, if started from a command-prompt or a BAT/CMD file, the whole parameter must be enclosed by quotation marks. Otherwise the command processor interprets the & char as separator for two separate commands.

Admin rights are required under Win 8, 10 and 11 (or an active USBDLM command interface).

Since V1.1 it finds devices which have a problem code in the device management.

Returns Errorlevels:

0 - successfully restarted the USB port
1 - no parameters
2 - invalid parameters
3 - given ID not found or no device is attached to the port
4 - restart tried but failed

Background information

This tool calls IOCTL_USB_HUB_CYCLE_PORT which, Microsoft says, power-cycles the USB port and thus initiates a re-enumeration of the attached device.
If there really is a power-cycle performed then it must be very short...
The function is available under XP but usually only for hubs which run with the Microsoft standard driver. 3rd party drivers usually return ERROR_UNKNOWN_FUNCTION.
Under Vista and Windows 7 it is no more supported by the Windows standard drivers, it always fails with ERROR_NOT_SUPPORTED.
Since Windows 8 it works again but in contrast to XP admin privileges are required. Without admin privileges it fails as under Vista and Win7 with ERROR_NOT_SUPPORTED or since Win10 version 1903 with ERROR_GEN_FAILURE, which both are quite missleading here since it's a privilege issue.


Last update: 17 June 2023

At Codeproject I have shown how to use IOCTL_USB_HUB_CYCLE_PORT: How to restart a USB port


  ListUsbDevs V1.0.0 - Lists USB Devices

ListUsbDevs lists all attached USB devices or checks if certain ones, specified by commandline, are attached.
ListUsbDevs [ID] [ID] [-na] [-w:nnnn]
Id can be
 a device instance ID (in quotation marks because it contains the & char)
 a driver key name
 a device location info
 a friendly device name (in quotation marks if it contains space or &)
 a port chain in UsbTreeView style
-na     no about info
-w:nnnn waits nnnn milliseconds on end
Wildcards can be used. Found devices must match all given IDs.


ListUsbDevs "USB\VID_0781&PID_5580\AA010319131128161470"

ListUsbDevs "USB\VID_0781&PID_5580\*" 1-4-2

ListUsbDevs {36fc9e60-c465-11cf-8056-444553540000}\0007

ListUsbDevs Port_#0002.Hub_#0008

ListUsbDevs "Sandisk Extreme"

ListUsbDevs 1-4-2

ListUsbDevs 1-4-2 -w:1000
If the & char is used in a parameter then, if started from a command-prompt or a BAT/CMD file, the whole parameter must be enclosed by quotation marks. Otherwise the command processor interprets the & char as separator for two separate commands.

Returns Errorlevels:

0 - at least one matchig device found
1 - no parameters
2 - invalid parameters
3 - device found but at least one has a problem code in the Device Manager
4 - no matching device found


Last update: 26 Feb 2023


  Device Cleanup Tool V1.3.1 - removes non-present devices from the Windows device management
Each once attached device leaves an entry in the Windows device management. By means of the Windows device manager you can delete one by one only. With this tool you can delete multiple or all non-present devices.
Non-PnP devices and 'soft' devices are not listed by default, this can be changed in the Options menu.




Last update: 19 April 2024


  Device Cleanup Cmd V1.2.1 - removes non-present devices from the Windows device management
This is the command line version of DeviceCleanup, see above.
DeviceCleanup V1.2.0
Uninstalls non-present devices
Freeware by Uwe Sieber -

DeviceCleanupCmd pattern1 [pattern2] [patternN] [-e:excludepattern1][-t][-s][-m:age][-v][-n]
-e:excludepattern  pattern not to remove
-t  test only
-s  skip creation of a system restore point
-m:age  minimum 'age' (last use of the device must be at least that old)
-v  verbose
-n  no wait when finished

Patterns are device IDs, device classes or friendly names. Wildcards can be used.

remove all devices whose device IDs begin with HID\VID_045E
DeviceCleanupCmd HID\VID_045E*

remove all devices whose device IDs contain VID_045E
DeviceCleanupCmd *VID_045E*

remove all bluetooth devices but not COM9 and COM10
DeviceCleanupCmd BTH* -e:"* (COM9)" -e:"* (COM10)"

remove all non present devices whose device class is Media
DeviceCleanupCmd Media

remove all devices not used for 1 year or more (m - month, d - days, i - minutes)
DeviceCleanupCmd * -m:1y

remove all devices
DeviceCleanupCmd *

show which devices would be removed (test mode)
DeviceCleanupCmd -t *
Non-PnP devices and 'soft' devices are not deleted because they are not automatically reinstalled. These are devices whose ID begins with
- SWD\
- SW\{

If you want to delete them, use a pattern that begins with one of these strings. Or use the GUI version of DeviceCleanup and activate the listing of these devices in the Options menu.


Last update: 19 April 2024

A related tool is DriveCleanup which removes devices only releated to drives and cleans some drive specific registy items.


  RunAsSystem V1.3.6 - starts a process in the SYSTEM context
RunAsSystem is helpful when admin privileges are not enough. For instance since Vista there are registry keys whose owner is the administrator but without the privileges to write or change the rights.

RunAsSystem passes the window style and its process priority to the exeucted process. Both can be overruled by commandline params.
By default it waits for the started process to end and then passes back its return code (aka errorlevel). But it is a Windows application, in a batch file you have to put a "start /wait" in front.
Started with -nowait it returns 0 immediately when the process has started.
Some programms do not work and end immediately in the System context because of missing settings for the current user.
Up to V1.2 this worked under XP only if the Sysinternal ProcessExplorer was running before, it seems that it changes the process access privileges to gather all the information but forgets to restore the found privileges.


RunAsSystem [-nowait] [-min|-max|-normal|-noact|-hid] [-low|-below|-normal|-above|-high] "executable" [params for executable]
RunAsSystem "%windir%\regedit.exe"

RunAsSystem "%windir%\System32\cmd.exe" /k dir /s "C:\System Volume Information"


Last update: 03 Jan 2023


  HidRun V1.0 - starts an executable hidden
HidRun starts a program hidden by starting it with the SW_HIDE flag.
Some programs ignore it!
HidRun "<exe to start>" <parameters>
hidrun calc

"C:\My Tools\HidRun.exe" "C:\Windows\System32\cmd.exe" /c del "%temp%\*" /s /q
Hint: On x64 Windows the Win32 version of HidRun would get redirected from C:\Windows\System32 to C:\Windows\SysWOW64.

HidRun is not a console application, so Windows does not create a new console window for it.
It does not wait for the started app to end, so it cannot pass the app's return value.

Return value (aka Errorlevel) is 0 if the app has been started, above 0 otherwise.


Last update: 11 Jan 2023


  CloseWindow V0.3 - closing windows
CloseWindow closes windows by commandline. For identifying the right window either the window text (the caption) or its class must be given at the commandline.
CloseWindow -text="windowtext" -class="windowclass"
Wildcards can be used.

Sample: Close all Windows Calculators

closewindow -text="Calculator" -count=999
Sample: Close Explorer window (XP) of drive U:
closewindow -text="U:\*" -class="ExploreWClass"
Sample: Close Explorer window (Vista+) of drive U:
closewindow -text="U:\*" -class="CabinetWClass"
The window class can be determined by my tool WinInfo

This works within the same user context only: If you want to close a program started "As Administrator" under Vista+ then CloseWindow must be started "As Administrator" too.


Last update: 20 Feb 2016


  FindEXE V0.5 - find the full path to an executable file
FindEXE is a commandline tool which shows the path of an executable which Windows would start.


FindExe calc


FindExe test.txt



Last update: 15 June 2017


  Sleep - Console program that waits for n milliseconds
Sample for waiting 1 second:
sleep 1000


Last update: 7 June 2007


  ConsoleNoClose - Deactivates the close button of one or all console windows
ConsoleNoClose disables the X button and removes the Close system menu item of all console windows when they become active.

It runs invisible in the background.

If it's started when another instance is running, it ends and leaves the previous instance untouched.

To remove a previous instance from memory, run it with parameter /R or /RH (hidden, no messagebox).

To do it for exactely one console window, start it with parameter /1. It will then disable the X button of the first console window that becomes active. Then it ends.

Started with /ALL it deactivates all menus of console windows. They cannot be closed, maximized, minimized then. No access to settings anymore.

With Fast User Switching it works within the same session only.

Under Vista and Windows 7..11 it must run elevated ("As Administrator") to do it with elevated console windows.

Sample to deactivate all system menu items of the next console window:

ConsoleNoClose /1 /ALL

It has no effect on the close button shown by the Windows TaskBar.


Last update: 12 Nov 2017


  BinHexDec - Convertor for Hex, Dec and Bin numbers


Last update: 08 May 2021


  COM Name Arbiter Tool V1.0.5 - gives control over reserved COM port numbers
Whenever a new COM port is installed, Windows looks for the first never used number. This ensures that there are no conflicts when two of the devices are attached at the same time.

In real live the users do not use their devices (as USB to COM adaptors) at the same time, but the COM numbers increase and increase because the reservation is not removed when the COM port device is uninstalled from the Device Manager. After 25 years Microsoft finally fixed this in Windows 10 version 1903, here the reservation is removed when a device is uninstalled, so this tool isn't needed anymore...

Windows stores used COM port numbers in the registry in the value ComDB under
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM Name Arbiter
By default there are 32 bytes with 8 bits in each byte. A set bit makes a port number (1..256) reserved. Over time Windows might exceed 256 ports, COM Name Arbiter Tool can handle this.

Changes are written immediately to the registry, admin privileges are required.

Removing the reservation does not do anything else than making Windows reassign the number to a new device when it is attached.
As long as the new device is not attached at the same time as the device which had these COM port before there is no problem.
If the devices are attached at the same time then the second one will not start because it cannot create its "COMx" symbolic link. This happens too if a new device wants to get a port which is supposed to be free because its arbiter bit is not set but in fact the port is in use! So don't clean up to much...

The tool can also uninstall (remove) devices.

Started with parameter /c it performs silently the "Clear unused reservations" operation.
Started with parameter /r it performs silently the "Remove non-present devices" operation.




Last update: 07 Nov 2021


  CreateFile Tester - Testing the Windows API call CreateFile
The CreateFile Tester is useful for testing different parameters for the Window API call CreateFile. Furthermore it can open files exclusively to test the behaviour of other programs when they try to open such an exclusiveley opened file.
Lots of storage information functions can be tested, the tool-tips of the buttons show some hints.




Last update: 27 Oct 2020


  IOCTL Decoder - decodes DeviceIoControl Codes
Decodes Windows DeviceIoControl hex values or names as listed here (in both directions).

The result fields have "Copy" context menu.





Last update: 22 Feb 2016


  LogWindowAtPoint - Logs Windows at a certain position
This tool is useful to identify randomly popping up windows.




Last update: 23 April 2024


  LogForegroundWindow - Logs the Windows which get the input focus
This tool is useful to identify windows which steal the focus from the active window.




Last update: 23 April 2024



Uwe Sieber