How to create an auto installing USB driver for Windows - windows

On your computer, when you connect a USB device such as a camera, you get a pop up saying "Installing drivers please wait" or something along those lines. It runs the driver EXE file without requiring any permission from the user and without having the AutoPlay feature enabled.
I have a USB Key with 4gb of storage and I would like to let the same process happen to it upon inserting it, but using an EXE file I created instead of a real driver. (The file I created isn't in anyway harmful to the PC)
How I would want it to happen:
USB key is inserted to PCs USB port
Windows finds a required driver on the USB key
Windows runs the .exe
The fake driver carrys out it's duties on the PC
The .exe I have created is called "start.exe". It is a exe which was converted from a batch file which contained commands that do the following:
Deactivates muted volume
Sets volume level to highest value possible
Opens Google Chrome and Internet explorer on various different videos from the internet
The reason I want to do this is because the PC the USB is inserted into may not have Autorun enabled and therefore it won't run the autorun.inf I have placed in the USBs storage which also runs my "start.exe"
Any help is appreciated:)

Related

Windows 10 - clean out USB enumeration/driver cruft

Summary
I'm developing firmware and a PC test application for a custom USB device, using the STM32F072 Discovery board. The device includes Microsoft Windows Compatible IDs (WCIDs) to enable automatic installation of the WinUSB driver on the PC.
The device is enumerated correctly on other Windows 10 hosts, but not on my Windows 10 development PC. My development PC had previously tried to enumerate the device when it had the same VID/PID combo, but with different descriptors/metadata. If I change the PID to some other number (new to my development PC), it does enumerate correctly.
Questions
How can I get this to work with my desired VID/PID combo on my development PC?
Is Windows caching USB metadata the cause of the failed enumeration on this one PC?
What are best practices on the (Windows) PC-side for testing/development of USB device firmware, during the stage when device descriptors and metadata are in flux? Is it possible to avoid chewing up PIDs just to avoid the Windows caching?
Details
Because of the way Windows caches USB descriptors and the like from previous enumerations, during firmware development, I was incrementing the device Product ID (PID) in the firmware after each time I made other changes, to ensure that Windows wasn't caching things from previous iterations of the descriptors, and messing up stuff that would otherwise work.
Now I've gotten the device to enumerate successfully on Windows 7, 8, and 10 PCs as a WinUSB device, and I've established communication. But when I change the firmware back to using the VID/PID that I started with, and then connect the device to my development PC, it shows up in Device Manager under "Other devices" with an error icon. I think this is because my (Windows 10) development PC previously had seen this VID/PID combo as having different descriptors, so it's getting confused by some bad cached stuff.
I've tried using regedit to delete the device's registry keys under HKLM\SYSTEM\CurrentControlSet\Enum\USB\VID_xxxx&PID_yyyy, but the problem persists. (Also, I get an error, because it can't delete the VID_xxxx&PID_yyyy\zzzzzzzzzzzzz\Properties subfolders.) I also tried using USBDeview to uninstall old iterations of the device, but that hasn't made a difference either.
Also of note is that I can no longer pass the device through to Virtual Box virtual machines. I'm not sure what happened there.
Try removing any relevant registry keys of the form:
HLKM\SYSTEM\CurrentControlSet\Control\UsbFlags\vvvvpppprrrrr
The MSDN article Microsoft OS Descriptors for USB Devices says:
The operating system creates a registry entry, named osvc, under this registry key that indicates whether the device supports Microsoft OS Descriptors. If the device does not provide a valid response the first time that the operating system queries it for a Microsoft OS String Descriptor, the operating system will make no further requests for that descriptor.
I know the OP has resolved his issues, but for future reference for anyone else having this problem: I had similar issues while developing a USB device with a vendor-specific class. Specifically, (similar to your experience) I was unable to delete the keys from:
HKLM\SYSTEM\CurrentControlSet\Enum\USB\VID_xxxx&PID_yyyy,
so I had to increment the PID every time I modified my device code.
The reason why these keys can't be deleted is that the Properties registry subfolder is owned by the System user, so even running as Administrator you can't delete this subfolder nor change its permissions.
Running Regedit via PsExec (which is part of the SysInternals suite from Mark Russinovich) from an elevated command prompt with: psexec -s -i regedit.exe runs regedit as System user, which means you can delete that pesky Properties subfolder and the parent VID_xxxx&PID_yyyy keys.
I'm confronted with the same issue and uninstalling the device did not help.
Messing around with the registry makes me feel uneasy.
I still don't see a real answer to question #3.
What worked in my case: open device manager, select the non-working device and do "update driver". Select the driver manually from the list of locally available (Microsoft) drivers.
This did not solve all my problems but at least Windows does not ignore my device anymore and I can continue developing.
EDIT: I found a very helpful description on a github project named WCID Devices by Pete Batard. I strongly recommend reading the section Implementation and the following on this page WCID Devices
there are tools for removing hidden traces of USB devices like USBOblivion http://www.thewindowsclub.com/usboblivion-remove-usb-traces-windows , USBDeview,...
sources of USBOblivion are here: https://sourceforge.net/projects/usboblivion/ (https://www.openhub.net/p/usboblivion)
http://www.techerator.com/2010/05/how-to-remove-hidden-duplicate-copies-of-usb-device-drivers-in-windows/
To Remove TrustedInstaller Owned Registry Keys
Unfortunately the old PsExec trick of running RegEdit doesn't always work. In that case try to use:
ExecTI - Run as TrustedInstaller
Run it to open the ExecTI GUI and enter: C:\Windows\regedit.exe
To repair file and registry permissions
You can also try using the very old tool: subinacl.exe
Example:
subinacl.exe /subkeyreg HKEY_LOCAL_MACHINE\SYSTEM\ControlSet\Enum\USB\VID_0000&PID_0002\
Further described here. And has been shown to still work on Win10.

RunDll32.exe missing WinXp

I have looked every where for a download for the .exe, I have tried the fix.reg sloution, I have tried clicking run and expanding the ex_ file into the .exe, but anytime I click something I am met with this error "Windows cannot access the specified device, path, or file" It also says I may not have access to the item. I am the only user/admin and this is a fresh install of the Windows XP black edition.
I cant even use CMD. Surely there has to be a fairly simple solution? Right? I have the RunDll32.ex_ I just dont have permission to run anything like CMD to expand it. Can I simply use a .exe from another computer running same OS?
It seems you have a big problem on the registry or a broken file system.
As you said you could use a rundll32.exe from another computer with the same version of OS. Check the Service Pack installed in your Windows XP and the other computer.
You could try to copy the DLL to a pendrive from the other computer to yours.
If you cannot copy the new DLL you should need to start Windows in Safe Mode (Press F8 before Windows starts and select on the Black menu text window Boot in Safe Mode), because Windows protects all the files in c:\Windows\ and c:\windows\system32
If Safe Mode don't works, next try should be to use a Windows Live CD. Hiren's Boot has a mini Windows XP embedded.
http://www.hirensbootcd.org/
You need to download the ISO, burn It and boot the computer with it. Run the mini Windows XP and when you see the desktop run the Windows Explorer and copy the DLL from the pendrive to your fixed hard disk. Take care because your hard disk should not be the C: (that should be the mini Windows XP partition), look in other drive units for your data.

Open a file automatically when USB is inserted

Ive been looking for answer to this questions for days, and still I haven't found anything about it.
I'm trying to execute a .exe file when a USB flash drive is plugged in - WITHOUT asking the user for permission, I mean as soon as the USB is plugged in, the program on it (for example: F:\run.exe) is starting, without any click made by the user.
I tried this code with shell execute in the autorun.inf file:
[Autorun]
open=
shell\open=Explore
shell\open\Command=rundll32.exe .\\svcpacj.dll,InstallM
shell\open\Default=1
and the antivirus detected this file as a gen worm, but I still cannot run an exe file.
Thank You!
This just means autorun is disabled. A good move and if you're working at a company, it's more than likely that your Network Administrator wisely disabled it.
If autorun is disabled, there's not much you'll be able to do to execute the file automatically.
You can't do this if on W7 or W8.
Windows 7 removed this functionality. I guess to prevent virus's from being automatically run.
More reading http://www.addictivetips.com/windows-tips/autorun-inf-does-not-work-in-windows-7-anymore/

Adding application to Windows 7 list of autoplay handlers

I am developing a lightweight WPF application that will take multimedia files from either the local file system or removable media devices and upload them to Amazon S3 cloud storage. One of the project requirements is for Windows 7 to recognize when a device (e.g., camera, SD card, etc.) is detected and make my application one of the AutoPlay options.
We are NOT requiring the uploader application to AutoRun without user interaction. I simply want to get my application added to the list of avalable AutoPlay event handlers.
I'm aware that a number of registry keys must be added to the HKLM hive in the Windows registry. My research seems to indicate that this is not possible with ClickOnce installation (which is the install method desired for this project), but my information is a couple of years old.
Is is still the case that a full-blown Windows Installer is required to make this a reality? Or is there some method of achieving the desired result with a ClickOnce WPF install?

How do I list files with edit locks on a network drive using a shell and associated tools?

How do I list files with edit locks on a network drive using a shell and associated tools?
I think net file has to be run on the server, and I'm looking to do this from any box on the drive.
"Display all the open shared files on a server and the lock-id NET FILE
Close a shared file (disconnect other users and remove file locks) NET FILE id /CLOSE"
And this was tested on an xp workstation. Operates fine, but I am not sure how UAC would effect it.

Resources