Didn understand nothing...
Ex: You want to read the .jar content and put in a textbox? or what?
So i'm currently working on a minecraft Server GUI and i ran in to this little problem.
I dont know how i can open a .Jar applet file inside the visual basic.
or it could also be cool if i could open a batch/console In my GUI.
I don't mean that i want to decompile it i just want so the text that are being written once you open the .jar or the bach file are being also written in my GUI but without acctualy opening the file it self just trough the GUI.
Hope i Explained it well...
Didn understand nothing...
Ex: You want to read the .jar content and put in a textbox? or what?
Well kind of but not the codes inside the file but once the jar is runned it opens a batch where it you can see ath the server is starting up and all that text and i want to open the program so it's kind of a batch file that is inside the visual basic program
It's Alittle bit hard to explain
Ill Upload pics just in a minute ;D to show what i want help with
This is what i mean
Hope u guys can help me
You want the text that is in the cmd window?
So here: ( I dont have time to explain it..)
Import the System.Text
Code:Dim Processo As New Process Dim ProcInfo As New ProcessStartInfo(YOUR PROCESS, PROCESS ATRIBUTES ) Processo.StartInfo = ProcInfo ProcInfo.UseShellExecute = False ProcInfo.RedirectStandardError = True ProcInfo.RedirectStandardInput = True ProcInfo.RedirectStandardOutput = True Processo.Start() Dim CMDString As New StringBuilder Dim ReadingCMDString As IO.StreamReader = Processo.StandardOutput While Not ReadingCMDString.EndOfStream Dim Line As String = ReadingCMDString.ReadLine Try If Not Line = vbNullString Then CMDString.AppendLine(Trim(Line)) End If Catch ex As Exception End Try End While ReadingCMDString.Close() Processo.WaitForExit(1) TextBox1.Text = CMDString.ToString Catch ex As Exception End Try
Last edited by Lyoto Machida; 04-24-2011 at 04:18 PM.
Thanks
Too Short
Got a new Problem when i have this code in and i start thr program and and i click the button to open the cmd it start's the cmd it self i dont need it to star only type in the text that the cmd is typing. and once it acctualy is open nothing happens in the cmd.? this is my code
Code:Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk TextBox3.Text = OpenFileDialog1.FileName Dim Processo As New Process Dim ProcInfo As New ProcessStartInfo(TextBox3.Text) Processo.StartInfo = ProcInfo ProcInfo.UseShellExecute = False ProcInfo.RedirectStandardError = True ProcInfo.RedirectStandardInput = True ProcInfo.RedirectStandardOutput = True Processo.Start() Dim CMDString As New StringBuilder Dim ReadingCMDString As IO.StreamReader = Processo.StandardOutput While Not ReadingCMDString.EndOfStream Dim Line As String = ReadingCMDString.ReadLine Try If Not Line = vbNullString Then CMDString.AppendLine(Trim(Line)) End If Catch ex As Exception End Try End While ReadingCMDString.Close() Processo.WaitForExit(1) Try TextBox1.Text = CMDString.ToString Catch ex As Exception End Try End Sub
Read the stdout of the process which you can start via. System.Diagnostics.Process.Start, and passing it a StartInfo that specifies for the StandardOutput to be redirected to your app (which you can read via. a SteamReader).
Lol spam.
Lyoto Machida (04-24-2011)
Try the following if you just want to have the window in your own program:
[highlight="VB.NET"]Imports System****ntime.InteropServices
Imports System.IO
Public Class Form1
#Region "DLLImports"
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function ShowWindow(ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Boolean
End Function
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
End Function
<DllImport("user32.dll")> _
Private Shared Function SetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Short, ByVal dwNewLong As Integer) As Integer
End Function
<DllImport("user32.dll")> _
Private Shared Function GetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As Integer
End Function
Const SW_MAXIMIZE As Integer = 3
Const GWL_STYLE As Integer = -16
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WindowToPanel("C:\Dokumente und Einstellungen\Xerxes\Desktop\random.bat", Panel1)
End Sub
Dim pProcess As New System.Diagnostics.Process
Private Sub WindowToPanel(ByVal Filepath As String, ByVal Panel As Panel)
Panel.Visible = False
Try
pProcess.StartInfo.FileName = Filepath
pProcess.StartInfo.WorkingDirectory = Path.GetDirectoryName(Filepath)
pProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized
pProcess.Start()
SetParent(pProcess.MainWindowHandle, Panel.Handle)
ShowWindow(pProcess.MainWindowHandle, SW_MAXIMIZE)
Dim frm As Integer = GetWindowLong(pProcess.MainWindowHandle, GWL_STYLE)
SetWindowLong(pProcess.MainWindowHandle, GWL_STYLE, frm And Not 12582912)
Panel.Visible = True
Catch ex As Exception
MessageBox.Show(ex.Message.ToString(), "Info")
End Try
Panel1.Visible = True
End Sub
[/highlight]
If you need to know what's in the cmd window listen to the guys below.
Last edited by Blubb1337; 04-25-2011 at 12:09 PM.
IDK how you did it. The code is not getting me any errors but once i run the program it just opens the cmd in a new window not inside my application this is my code.
Code:Imports System****ntime.InteropServices Imports System.IO Public Class Form1 #Region "DLLImports" <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _ Private Shared Function ShowWindow(ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Boolean End Function <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _ Private Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr End Function <DllImport("user32.dll")> _ Private Shared Function SetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Short, ByVal dwNewLong As Integer) As Integer End Function <DllImport("user32.dll")> _ Private Shared Function GetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As Integer End Function Const SW_MAXIMIZE As Integer = 3 Const GWL_STYLE As Integer = -16 #End Region Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Dim pProcess As New System.Diagnostics.Process Private Sub WindowToPanel(ByVal Filepath As String, ByVal Panel As Panel) Panel.Visible = False Try pProcess.StartInfo.FileName = Filepath pProcess.StartInfo.WorkingDirectory = Path.GetDirectoryName(Filepath) pProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized pProcess.Start() SetParent(pProcess.MainWindowHandle, Panel.Handle) ShowWindow(pProcess.MainWindowHandle, SW_MAXIMIZE) Dim frm As Integer = GetWindowLong(pProcess.MainWindowHandle, GWL_STYLE) SetWindowLong(pProcess.MainWindowHandle, GWL_STYLE, frm And Not 12582912) Panel.Visible = True Catch ex As Exception MessageBox.Show(ex.Message.ToString(), "Info") End Try Panel1.Visible = True End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click OpenFileDialog1.ShowDialog() End Sub Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk TextBox1.Text = OpenFileDialog1.FileName WindowToPanel(TextBox1.Text, Panel1) End Sub End Class
You did get help with that...you just chose to ignore it because it wasn't a direct spoonfeed.
As simple as can be:
[highlight=vb.net]
Private Function readProcessOutput(ByVal filePath As String) As String
Dim retVal As String = String.Empty
Dim proc As New Process With {.StartInfo = New ProcessStartInfo With {.FileName = filePath, .RedirectStandardOutput = True, .UseShellExecute = False}}
proc.Start()
Using sRead As IO.StreamReader = proc.StandardOutput
retVal = sRead.ReadToEnd
End Using
proc.WaitForExit(0)
Return retVal
End Function
[/highlight]
All you need to do is plug in the location of the process, and then assign the result to a textbox:
[highlight=vb.net]
TextBox1.Text = readProcessOutput(Environment.GetFolderPath(Enviro nment.SpecialFolder.Desktop) & "\test.bat")
[/highlight]
Doesn't come any simpler than that.
Last edited by Jason; 04-26-2011 at 12:28 PM.
You can win the rat race,Originally Posted by Jeremy S. Anderson
But you're still nothing but a fucking RAT.
++Latest Projects++
[Open Source] Injection Library
Simple PE Cipher
FilthyHooker - Simple Hooking Class
CLR Injector - Inject .NET dlls with ease
Simple Injection - An in-depth look
MPGH's .NET SDK
eJect - Simple Injector
Basic PE Explorer (BETA)
Thank You alot
Could you just help men once again
what if i want to open the batch file froms some other folder then desktop.Code:TextBox1.Text = readProcessOutput(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\test.bat")
Can i instead of typinf desktop or some other specialfolder type in textbox2.text?
You can win the rat race,Originally Posted by Jeremy S. Anderson
But you're still nothing but a fucking RAT.
++Latest Projects++
[Open Source] Injection Library
Simple PE Cipher
FilthyHooker - Simple Hooking Class
CLR Injector - Inject .NET dlls with ease
Simple Injection - An in-depth look
MPGH's .NET SDK
eJect - Simple Injector
Basic PE Explorer (BETA)
danishfps (04-28-2011)