I want to move my program to USB memory stick. It will run only on memory stick and would not be copied (written on C# and has nearly 3GB of database). Where can I find a good source for that and/or how can I do that?
-
3What's the actual problem? Why cannot you write it as you always write programs? The program, after being run, won't even know whether it was loaded to memory from HDD or from a USB drive, that's the OS's business. Just use relative path for files and that's it, I guess. – Kos Nov 21 '10 at 15:55
-
How to do that? Write your own operating system or find an OS that will fit in a USB stick alongside your 3GB database. – bcosca Nov 21 '10 at 15:59
-
Actual problem is how to make that program runs only on memory stick. It must not be copied to harddrive or somewhere else. Even if the user copy to hdd, it should not run. – Savas Nov 21 '10 at 16:05
2 Answers
Allow me to disagree with nmichaels, it is possible to check in C# if your running from removable storage or hard drive.
Check this thread: How to detect if any specific drive is a hard drive?
However, it would be too easy to reverse the thing and allow it to run on hard drives.
As an additional protection, you can read the USB drive serial and if it doesn't match, kill the program.
OR... you if want to be hardcore, use a specific USB drive model, and read the VID/PID, or the chip itself (check mass production tool).
In the end, if the program worths it, someone would still reverse it and break the protection scheme :)

- 1
- 1

- 1,656
- 1
- 17
- 39
What you described can't reasonably be done. If a user can run the program, they can run it. It doesn't matter whether they loaded it from your USB stick or not. You can write it such that it assumes it's being run from the USB stick (with relative paths, per @Kos's comment) but that will in no way prevent people from copying it to their hard drives and running it. Since you don't know where a USB stick will be mounted ahead of time, you can't even use absolute paths.

- 49,466
- 12
- 107
- 135
-
So if I want to distribute my program in memory stick I would simply copy that and there's no way to avoid copying. – Savas Nov 21 '10 at 19:01
-
@Savas: pretty much. You can spend money on drm schemes, but they don't work. – nmichaels Nov 22 '10 at 02:20