I'm new to this forum but I I'm trying to find an answer to my question. I've developed an application in VB.Net using the console option. This program runs from the command-prompt and is very basic. The issue I am having is:
1. I compile the program and copy the EXE to a USB key
2. I boot onto the USB key which has basic DOS loaded
3. I attempt to execute the EXE I created in VB.Net and get
the following error:
"this program can not be run in dos mode"
I need to find out how I can get my DOS based application to run under real-dos mode, or if it's possible using vb.net?
Thanks in advance for any assistance.
Here is my code:
Imports System.IO
Module Module1
Public _IPADDRESS As String = ""
Public _GATEWAY As String = ""
Public _SUBNET As String = ""
Public _IPADDRESS_HEX As String = ""
Public _GATEWAY_HEX As String = ""
Public _SUBNET_HEX As String = ""
Public _MAC As String = ""
Public _MAC_Hex As String = ""
Public arrData As Array
Public pleasefix As Integer = 0
Sub Main()
arrData = Command.Split(" ")
If Not arrData.Length > 1 Then
Console.WriteLine("")
End If
redo:
AskMainIP()
GateWayIP()
AskSubnet()
GetMAC()
VerifyInfo()
If pleasefix = 1 Then
pleasefix = 0
GoTo redo
End If
ExecuteCommands()
End Sub
Private Sub VerifyInfo()
Console.WriteLine()
Console.WriteLine("*** Please verify the information below ***")
Console.Write("Does the above information look correct? (Y/n)")
Dim response As Char = Console.ReadLine
If response = "y" Or response = "Y" Or response = "yes" Or response = "" Then
Else
pleasefix = 1
End If
End Sub
Private Sub ExecuteCommands()
Execute("")
End Sub
Private Sub Execute(ByVal TempCmd As String, ByVal msg As String)
Console.WriteLine(" * " & msg)
Shell(TempCmd, AppWinStyle.Hide, True)
End Sub
Private Sub GetMAC()
For Each nic As System.Net.NetworkInformation.NetworkInterface In System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
Console.WriteLine(String.Format("The MAC address of {0} is{1}{2}", nic.Description, Environment.NewLine, nic.GetPhysicalAddress()))
Exit For
Next
Console.WriteLine("Above are the found NICs with MAC addresses")
Console.Write("Please enter the MAC address you will be using: ")
_MAC = Console.ReadLine
If _MAC = "" Then
_MAC = "00 00"
End If
End Sub
Private Sub AskMainIP()
Console.WriteLine()
Console.Write("Please enter the IP for this server (xxx.xxx.xxx.xxx): ")
Try
_IPADDRESS = Console.ReadLine()
If _IPADDRESS = "" Then End
Console.WriteLine("The IP you selected was: " & _IPADDRESS)
Dim ChopIP() As String = _IPADDRESS.Split(".")
Dim CLASS_A As Integer = ChopIP(0)
Dim CLASS_B As Integer = ChopIP(1)
Dim CLASS_C As Integer = ChopIP(2)
Dim CLASS_D As Integer = ChopIP(3)
Dim CLASS_A_HEX As String = Convert.ToString(CLASS_A, 16)
Dim CLASS_B_HEX As String = Convert.ToString(CLASS_B, 16)
Dim CLASS_C_HEX As String = Convert.ToString(CLASS_C, 16)
Dim CLASS_D_HEX As String = Convert.ToString(CLASS_D, 16)
Dim HexIP As String = CLASS_A_HEX & " " & CLASS_B_HEX & " " & CLASS_C_HEX & " " & CLASS_D_HEX
Console.WriteLine("The HEX value of this IP is: " & HexIP)
_IPADDRESS_HEX = HexIP
Catch ex As Exception
Console.WriteLine("")
Console.WriteLine("Error, invalid IP, please enter in the form of ###.###.###.###")
End
End Try
End Sub
Private Sub AskSubnet()
Console.WriteLine("* leave blank to default to 255.255.255.0 *")
Console.Write("Please enter the Subnet mask IP for this server (xxx.xxx.xxx.xxx): ")
Try
_SUBNET = Console.ReadLine()
If _SUBNET = "" Then _SUBNET = "255.255.255.0"
Console.WriteLine("The Subnet mask IP you selected was: " & _SUBNET)
Dim ChopIP() As String = _SUBNET.Split(".")
Dim CLASS_A As Integer = ChopIP(0)
Dim CLASS_B As Integer = ChopIP(1)
Dim CLASS_C As Integer = ChopIP(2)
Dim CLASS_D As Integer = ChopIP(3)
Dim CLASS_A_HEX As String = Convert.ToString(CLASS_A, 16)
Dim CLASS_B_HEX As String = Convert.ToString(CLASS_B, 16)
Dim CLASS_C_HEX As String = Convert.ToString(CLASS_C, 16)
Dim CLASS_D_HEX As String = Convert.ToString(CLASS_D, 16)
Dim HexIP As String = CLASS_A_HEX & " " & CLASS_B_HEX & " " & CLASS_C_HEX & " " & CLASS_D_HEX
Console.WriteLine("The HEX value of this IP is: " & HexIP)
_SUBNET_HEX = HexIP
Catch ex As Exception
Console.WriteLine("")
Console.WriteLine("Error, invalid IP, please enter in the form of ###.###.###.###")
End
End Try
End Sub
Private Sub GateWayIP()
Console.WriteLine()
Dim _IPADDRESS As String = ""
Console.Write("Please enter the Gateway IP needed for this server (xxx.xxx.xxx.xxx): ")
_IPADDRESS = Console.ReadLine()
If _GATEWAY = "" Then End
Console.WriteLine("The Gateway IP you selected was: " & _GATEWAY)
Try
Dim ChopIP() As String = _GATEWAY.Split(".")
Dim CLASS_A As Integer = ChopIP(0)
Dim CLASS_B As Integer = ChopIP(1)
Dim CLASS_C As Integer = ChopIP(2)
Dim CLASS_D As Integer = ChopIP(3)
Dim CLASS_A_HEX As String = Convert.ToString(CLASS_A, 16)
Dim CLASS_B_HEX As String = Convert.ToString(CLASS_B, 16)
Dim CLASS_C_HEX As String = Convert.ToString(CLASS_C, 16)
Dim CLASS_D_HEX As String = Convert.ToString(CLASS_D, 16)
Dim HexIP As String = CLASS_A_HEX & " " & CLASS_B_HEX & " " & CLASS_C_HEX & " " & CLASS_D_HEX
Console.WriteLine("The HEX value of this Gateway IP is: " & HexIP)
_GATEWAY_HEX = HexIP
Catch ex As Exception
Console.WriteLine("")
Console.WriteLine("Error, invalid IP, please enter in the form of ###.###.###.###")
End
End Try
End Sub
End Module