Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Partitioning by VB.Net

Posted on 2013-05-16
16
Medium Priority
?
963 Views
Last Modified: 2013-08-19
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?
0
Comment
Question by:Soumen-Roy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
16 Comments
 
LVL 42

Assisted Solution

by:Meir Rivkin
Meir Rivkin earned 1000 total points
ID: 39170623
u can use diskpart.exe to create the partition.
start with creating the diskpart script with relevant information.
example:
            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
            sb.AppendLine("EXIT");
            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

0
 

Author Comment

by:Soumen-Roy
ID: 39170828
Wow!

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)
0
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 39170886
do u have the installer webpage?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Soumen-Roy
ID: 39170945
no, its a winform project, not webbased
0
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 39171007
I mean where is the FreeDOS / Linux installer located?
0
 

Author Comment

by:Soumen-Roy
ID: 39171098
In exe path i.e. debug folder. When I will make the setup, it will be in the software setup, I guess
0
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 39171151
what kind of installer is it?
MSI? NSIS?
0
 

Author Comment

by:Soumen-Roy
ID: 39171178
http://www.freedos.org/download/

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
0
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 39171231
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.
http://marc.herbert.free.fr/linux/freedos_no_removable.html

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.
0
 

Author Comment

by:Soumen-Roy
ID: 39172113
I need some time to explore and let you know what is the status
0
 

Author Comment

by:Soumen-Roy
ID: 39176668
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?
0
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 39176734
DiskPart.exe should be located here:
C:\Windows\System32\diskpart.exe
the following OS should have it: Windows Vista, Windows® XP, and the Windows Server 2003® family:
http://www.experts-exchange.com/Programming/Languages/.NET/Q_28129727.html#a39176668
here's a direct download link:
http://download.microsoft.com/download/win2000platform/DiskPart/1.00.0.1/NT5/EN-US/diskpart_setup.exe
0
 

Author Comment

by:Soumen-Roy
ID: 39196145
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
        Try
            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
            sb.AppendLine("EXIT")
            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
            MessageBox.Show(ex.Message)
        End Try

    End Sub
End Class

But I am getting error. I tried from command line also. I am attaching the screen shots here
Error.zip
0
 
LVL 83

Accepted Solution

by:
David Johnson, CD, MVP earned 1000 total points
ID: 39301188
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.
0
 

Author Closing Comment

by:Soumen-Roy
ID: 39422387
Thanx
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question