I need to disable USB on Windows Mobile. How to disable USB on Windows Mobile using Compact Framework 2.0 (C#)? I am using OpenNETCF too. If it has some class to disable USB, I can use it too.
-
1I don't expect that there is an API to do this. – H H May 03 '11 at 07:07
-
1Why is your code so special that it ought to be allowed to do this? – Damien_The_Unbeliever May 03 '11 at 07:25
-
It is the security enforced by enterprise to thier employee. – Let me Ask May 03 '11 at 08:47
-
1If it's windows mobile 6.1 or later, I wouldn't try and do this myself - there's a pack for System Center (Mobile Device Management) that lets you have granular control over such features using group policy. – Damien_The_Unbeliever May 04 '11 at 12:26
2 Answers
A bit of advice, you have to implement both operations to lock / unlock the usb device. Because if you can't unlock it you must perform a clean boot.
You should provision the device with this specific policies
<!-- DenyRAPI.xml !-->
<wap-provisioningdoc>
<characteristic type="SecurityPolicy">
<parm name="4097" value="0"/>
</characteristic>
</wap-provisioningdoc>
<!-- AllowRAPI.xml !-->
<wap-provisioningdoc>
<characteristic type="SecurityPolicy">
<parm name="4097" value="2"/>
</characteristic>
</wap-provisioningdoc>
I provide a link to the original post in which is suggested that you create the cabs. Original Post
I have used another approach to read the XML configuration and then using the following method I execute the provisioning
Microsoft.WindowsMobile.Configuration.ConfigurationManager.ProcessConfiguration(XmlDocument,boolean);
Another option is to use builds the cabs and install them by using wceload.exe

- 1,301
- 9
- 10
If your application is code-signed and running in full trust, then you have access to protected registry keys. You could then try to edit or remove the various USB device driver configuration registry values. Then you might have disabled USB.
Edit: Possibly involved registry keys:
HKEY_LOCAL_MACHINE\Drivers\USB\FunctionDrivers

- 24,991
- 10
- 72
- 122
-
I will try and let you know. Can you give me example of "protected registry keys"? – Let me Ask May 03 '11 at 08:48