Hello,
This is my first post here. Been developing in the .NET platform for a long time now; however I mostly focused on developing web application, enterprise level applications. I have been asked to develop a windows application that will run off of a USB drive. I need to find out how to make it so that the application only runs when the USB is in. It doesn't matter if the USB does an install first or not, but the requirement is that the USB must be in for the application to start up. The application will be built using .net 4.5 in C#.
I haven't done this before so any help will be appreciated.
One thing I forgot to mention in the original post is that each exe needs to be bound to the particular USB its put on. This means that if someone copied it from one USB to another that it wouldn't function. I think I need to look at the vid or the pid.
Loading
VulpesPosted Apr 24, 2014, 11:22 AM
However, you might now have a problem hard-coding the id within the application because sophisticated users could read it using a .NET dis-assembler (and even change it) and then use the appropriate USB drive to run the program.
If this is a serious security concern, you might therefore need to use some sort of encryption or obfuscation.
jakub kazmierskiPosted Apr 24, 2014, 1:32 PM
I think I will have to write a separate application that first checks the USB hid and pid, writes it to where ever I will store the "license key" in the application that will be executed off of the USB, then compiles that said application and copies it to the USB.
I think the problem I was having was how will the compiled application know that it's running on the correct USB. The only way I can think to solve it is to get create a compiler application that compiles the source onto the USB. Unless there are already builder that can do that with a build .exe.
It seems like a weird little problem.
jakub kazmierskiPosted Apr 24, 2014, 10:42 AM
My fault but I forgot to add that I need to make sure that if the file is moved from one usb to another that it doesn't work. It needs to only run on the USB that it was originally installed on. In the code you provided it just checks that it's being executed from a USB. I actually need to bind each exe to a specific USB flash drive.
I think I will need it to check for the vid or the pid. But that means that each executable would have to be made for that particular USB device to compare the acceptable id.
VulpesPosted Apr 24, 2014, 10:09 AM
You'll need to add a reference to System.Management.dll for this to work: