Does anyone know how can I prevent a specific USB disk/flash from installing in a Windows Service? I don't want to disable all usb ports, I just prevent a specific usb disk from installing. I'm using windows 7.
Yes, is possible disable USB disk, using Kernel-Mode Filter Driver.
http://msdn.microsoft.com/en-us/library/windows/hardware/ff545890%28v=vs.85%29.aspx
Few years ago, I wrote project, that accept only USB disks with specified VID\PID.
Unfortunately, I can not find this project.
Related
I'm using win7-64bit
I am in the process of developing a user interface for a USB CDC device (used as a flash programmer) I am adding in exception handlers and constantly testing, but whenever something does go wrong and the program crashes, the USB device disappears from device manager and will not reconnect. I uninstall and reinstall the driver (which I have made automatic in the c# GUI) but this doesn't fix it either. Nor does resetting the computer, changing USB ports, etc.. The only way I know to fix it is to delete the registry entries for the specific PID / VID stuff and then unplug the USB and plug it back in. Windows the reinstalls it (because it still has the inf file) and it works perfectly. This shouldn't be an issue in the release version, but for testing it has been a real problem constantly going through that process.
My question is why is this happening?
I'm currently working on getting a Leonardo device recognized and communicating with my app over a serial port in C# for the Windows 8 App Store. I'm using http://msdn.microsoft.com/en-us/library/windows/hardware/dn312121(v=vs.85).aspx#step2 as a guide, in conjunction with http://code.msdn.microsoft.com/windowsapps/USB-CDC-Control-sample-5ba19caa to guide me.
I'm having problems however in the sense that my Arduino device isn't showing up despite me entering my PID/VID and Class/Subclass/Protocol so I feel I'm missing some steps and was hoping someone that has experience with this could point me to a more specific/granular example.
My device is an Arduino Leonardo and I'm running windows 8.1 using Visual Studio 2013 Ultimate, code is in C#
Any help is appreciated!
Just general thoughts on regular windows applications (not aware of W8 AppStore):
Might help or might not, in the second case, sorry for wasting your time...
To get a "regular COM" device in Windows, without any additional drivers, you should make the device appear as USB Communication Device Class (aka CDC) - this is, among others, done via the appropriate class/subclass/protocol. The VID/PID don't care. This means the device should provide CDC/ACM USB descriptors to the enumerating USB host (windows) and implement the required endpoints and commands - supposedly there is already something existing for your board and you downloaded the firmware to it, right? You might want to try to connect such configured device to windows and after successful enumeration, new COM port should appear. If you program regular application, you just connect to such COM port via SerialPort class instance, no matter it is provided via USB subsystem... If this works, you should be able to start the AppStore part (where I have no clue how to help).
I'm just going to answer this as not currently possible. I ended up writing a desktop WPF application using metro UI/UX guidelines. Between that and ClickOnce deployment the store app feel is fairly well recreated, despite the store being ideal.
I sincerely hope that Microsoft decides to support this in the near future, the Metro SDK is really nice and I would love to eventually port it.
I want to disable/enable all usb ports at once.
I tried the following:
Changed the registry (with admin privileges):
//disable USB storage...
Microsoft.Win32.Registry.SetValue(#"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR", "Start", 4, Microsoft.Win32.RegistryValueKind.DWord);
//enable USB storage...
Microsoft.Win32.Registry.SetValue(#"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR", "Start", 3, Microsoft.Win32.RegistryValueKind.DWord);
I also tried Hardware Helper Library for C# - even not detecting the devices
and Win32 API function to programmatically enable/disable device
I am using windows 8.1 64bit if it matters, and I compile the code with platform target = any CPU if it matters again.
EDIT:
Still not working.
I want to block/disable all the usb devices then even connect in the future and not only the current.
Can anyone help me?
Would appreciate your help.
That registry key prevents the USBSTOR driver from loading. It won't unload it if it is already in use. So you will not see any effect until after reboot.
make USBSTOR value to 4 and restart the PC. Another way is to disable in BIOS. Most of the computer manufacturers support this. But it will disable not only storage but all.
well guys, i am part of one team. (I dont have the project yet, i am new).
They did a application using gps, problem is it fail sometimes...
why? they think gps fails because users has the device in "energy saving" mode; then the device hibernates
after 5 minutes if they dont use it.
GPS brings sometimes bad coordinates (for example coordinate shows users is on "SEA" or in "Japan". I repeat, My partners thinks problem is because device is in "energy saving" mode. how can i change this configuration with C# while application is running (maybe back old configuration when application has been closed).
I am using this library.
using Microsoft.WindowsMobile.Samples.Location;
I can't check if it works because now i dont have a device, and i my computer doesn't have GPS, do you have any idea for i can check the application?.
i am using
`"Windows Mobile 6.0 SDK"`
You can install networking functionality while using the Microsoft Device Emulator. This blog explains how to setup network functionality on Windows 7. Follow the official documentation if you're not using Windows 7.
You can emulate GPS functionality using the FakeGPS program supplied by Microsoft. If you want anything close to real data you'll need a text file containing raw NMEA to feed into FakeGPS. You can simply record bytes passed through the GPS COM port to a file to generate a NMEA file. If fake GPS doesn't like your file then remove the non-standard NMEA lines and try again.
You should do some research on Windows Mobile Power Management first to understand the problem. The quickest hack is to simply call SystemIdleTimerReset() more frequently than the battery idle timeout (use SystemParametersInfo() and SPI_GETBATTERYIDLETIMEOUT) to prevent the device from sleeping. This will decrease the battery life of the device! There are other more elegant solutions available such as using the Power Management API.
I need to connect and disconnect USB programmatically. That is, I have inserted the USB device. I need to transfer the file using C#, .NET application. The application will watch the particular folder and transfer the file from that folder to a USB drive. I need to disconnect the USB device after the file is transfered and connect the USB when needed - without unplug and replug.
What would be some code to do it or is there any DLL file available?
Main thing: NOTE, NOTE: Without unplugging and replugging the USB device.
If your goal is to make a certain disk volume unavailable while you're not using it, a more sensible approach might be to use the volume management APIs, e.g. by using the IOCTL_VOLUME_OFFLINE control code. (I'm assuming that you know which drive letter belongs to your USB disk.)
Alternatively, you can disable and enable the volume device programmatically with the CfgMgr / SetupAPI -- the same as right-clicking the volume in Device Manager and choosing Disable would do. (For information about using SetupAPI, please review the DevCon sample code provided with the Windows WDK, and see MSDN for functions such as SetupDiChangeState.)
The latter option might require a privileged user account.
I'm not exactly sure, but it can be done. In Linux, I've experienced certain situations where power is disconnected to a device programmatically. The kernel usually does this if the connected USB device is exhibiting too many errors. So, it should be possible to do this even in Windows. You may need to write your own external DLL to do it though.