c# – Automatic mounting of a hard disk partition

Question:

Hello. It costs Ubuntu 13.04 + Windows 8. There is a hard disk partition W: and it plays the role of storage for Apache.
On Ubuntu it mounts to /var/www and on Windows just W: and everything is set to it. I did this myself so that I could code under different axes without transferring files, and it’s just very convenient – like a working disk.
The problem is that Ubuntu removes the letter during mounting and under Windows you have to manually assign it all the time. Moreover, Ubuntu overwrites the letter, even when I don’t go into it – probably even at the grub stage.
Does anyone know how to write a script / program for Windows using code (C / C ++ / C #, Java, DOS .bat, etc.) so that it can be added to autorun and it is automatically mounted at the entrance.

Answer:

Hello, I won't provide a complete solution, but maybe I can push you in the right direction. After reading your task, I think you need to import functions from kernel32.dll. From what I understand, the SetVolumeMountPoint method may suit you.

SetVolumeMountPoint – w32api – Windows API Reference

Try it. See also C# how to mount and unmount a virtual drive . Not compatible then, but to understand the principle.

Scroll to Top