none
Windows 8.1 clearing plug-and-play state if device not used for 30 days

    Question

  • Windows 8.1 contains a scheduled task (Plug and Play Cleanup) that clears down the state (i.e. removes) a plug-and-play device from the system if it has not been used for more than 30 days.

    This is a problem as all the configuration (such as COM port mappings for a USB cellular modem) is lost

    Is it possible to configure a plug-and-play driver (i.e. USB) so that Windows 8.1 doesn't automatically clear it state if not used for longer than 30 days?

    Tuesday, June 23, 2015 8:29 AM

Answers

  • PnPClean only removes non-present devices, so your COM port shouldn't be deleted. In any event, PnPClean looks at the last time the device was removed. You can query this using SetupDiGetDeviceProperty and specify DEVPKEY_Device_LastRemovalDate. You should be able to set it using SetupDiSetDeviceProperty. As I recall, if you set it to zero, it won't be a removal candidate any longer.

     -Brian


    Azius Developer Training www.azius.com Windows device driver, internals, security, & forensics training and consulting. Blog at www.azius.com/blog

    Friday, June 26, 2015 9:07 PM
    Moderator

All replies

  • PnPClean only removes non-present devices, so your COM port shouldn't be deleted. In any event, PnPClean looks at the last time the device was removed. You can query this using SetupDiGetDeviceProperty and specify DEVPKEY_Device_LastRemovalDate. You should be able to set it using SetupDiSetDeviceProperty. As I recall, if you set it to zero, it won't be a removal candidate any longer.

     -Brian


    Azius Developer Training www.azius.com Windows device driver, internals, security, & forensics training and consulting. Blog at www.azius.com/blog

    Friday, June 26, 2015 9:07 PM
    Moderator
  • Thanks for the reply Brian.

    Could you clarify, are these properties that can be set by user code or are they set by the driver?

    The reason the COM port was removed is that the modem is only used periodically and was left powered down for more than 30 days.

    Also, do you have any reference to this field (DEVPKEY_Device_LastRemovalDate). I've done a quick Google and can't see any reference on MSDN or any Microsoft site.

    Cheers

    Monday, June 29, 2015 7:57 AM
  • As far as I know, those properties are currently only set by the PnP manager from kernel mode, and they are read from user mode. I don't see any reason why you couldn't set them from user mode.

    DEVPKEY_Device_LastRemovalDate is defined in the Win8.1 SDK or WDK, I see it here: C:\Program Files (x86)\Windows Kits\8.1\Include\shared\devpkey.h

     -Brian


    Azius Developer Training www.azius.com Windows device driver, internals, security, & forensics training and consulting. Blog at www.azius.com/blog

    Monday, June 29, 2015 10:22 PM
    Moderator