• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1053
  • Last Modified:

Partitioning by VB.Net

I want to make a tiny partition from C drive and install DOS (only DOS / Linux / Free DOS just for booting purpose) in that partition, programmetrically. I want to make it first in boot sequence.

I am using XP SP3 / Win7 32/64 bit. I know VB.Net. How to do that?
  • 8
  • 6
2 Solutions
Meir RivkinFull stack Software EngineerCommented:
u can use diskpart.exe to create the partition.
start with creating the diskpart script with relevant information.
            string partitionLetter = "Q";
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("SELECT DISK=0");//Select the first disk drive
            sb.AppendLine("CREATE PARTITION PRIMARY");//create new partition
            sb.AppendLine("ASSIGN LETTER=" + partitionLetter);//assign letter
            sb.AppendLine("FORMAT FS=NTFS LABEL=\"TPS\" QUICK");//format new partition
            File.WriteAllText(@"c:\temp\part.scr", sb.ToString());//create diskpart script
            Process.Start("diskpart.exe", @"/s c:\temp\part.scr");//run the script

Open in new window

Soumen-RoyAuthor Commented:

Thats a nice way. But how to install FreeDOS / Linux after that and make it as first bootable partition, programmetically? (second part of my question)
Meir RivkinFull stack Software EngineerCommented:
do u have the installer webpage?
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Soumen-RoyAuthor Commented:
no, its a winform project, not webbased
Meir RivkinFull stack Software EngineerCommented:
I mean where is the FreeDOS / Linux installer located?
Soumen-RoyAuthor Commented:
In exe path i.e. debug folder. When I will make the setup, it will be in the software setup, I guess
Meir RivkinFull stack Software EngineerCommented:
what kind of installer is it?
Soumen-RoyAuthor Commented:

an iso setup is there. but i am not sure how it can be incorporated programmetrically to install. probably extrating by 7zip? i am not sure, really
Meir RivkinFull stack Software EngineerCommented:
i don't think u can silent install freedos on your HD.
follow this steps from this website which requires no bootable or something like that.

download this installer from here: http://marc.herbert.free.fr/FDOS/beta9pre5/
once unzip the installer, goto FREEDOS\SETUP\INSTALL\INSTALL.EXE and run it.
Soumen-RoyAuthor Commented:
I need some time to explore and let you know what is the status
Soumen-RoyAuthor Commented:
I searched for diskpart.exe to use as suggested by you, but diskpart has some setup type. how to integrate that with my software? Where I can found the diskpart.exe only to download what I can use as suggested by you? can you please help?
Meir RivkinFull stack Software EngineerCommented:
DiskPart.exe should be located here:
the following OS should have it: Windows Vista, Windows® XP, and the Windows Server 2003® family:
here's a direct download link:
Soumen-RoyAuthor Commented:
As suggested by you I tried with the following code in VB.Net

Imports System.Text

Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            Dim partitionLetter As String = "Q"
            Dim sb As StringBuilder = New StringBuilder()
            sb.AppendLine("SELECT DISK=0") 'Select the first disk drive
            sb.AppendLine("CREATE PARTITION PRIMARY") 'create new partition
            sb.AppendLine("ASSIGN LETTER=" + partitionLetter) 'assign letter
            sb.AppendLine("FORMAT FS=FAT32 LABEL=""FD"" QUICK") 'format new partition
            System.IO.File.WriteAllText("c:\part.scr", sb.ToString()) 'create diskpart script
            Process.Start("diskpart.exe", "/s c:\part.scr") 'run the script
        Catch ex As Exception
        End Try

    End Sub
End Class

But I am getting error. I tried from command line also. I am attaching the screen shots here
David Johnson, CD, MVPOwnerCommented:
the instructions given depend upon the fact that there is in fact unallocated space on the hard drive or that it is a blank hard drive.

I would greatly suggest that you use a virtual machine to test things. dosbox comes immediately to mind

Dos / linux booting is pretty much foreign to modern operating systems and they require their own boot loader i.e. grub.  so now we are into a multiboot situation.

Since windows 7 is in the mix... then we are dealing with the bcd store. suggest you become familiar with the workings of easybcd http://neosmart.net/EasyBCD/  and look at how he handles the multiboot situation.

Dos boots from the first active partition and that partition MUST not be NTFS .. I think freedos only understands fat and maybe not even fat32 partitions.

This is a a fairly involved project and not something that I'd suggest a novice to cut his teeth on.
Soumen-RoyAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 8
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now