Solved Bind Exe

July 31, 2011 at 11:54:45
Specs: Windows 7
Hey
I have exe file and i want to add to another one and i want this one start after the first is finish

See More: Bind Exe

Report •


✔ Best Answer
July 31, 2011 at 15:25:39
If you the programs yourself you must have the source code, even if it is only compiled batch script.

.EXE files are binary files which means they are just a load of numbers, numbers that the CPU can understand. The Source code is what the programmer wrote that humans can understand that is then compiled into an .EXE.

The reason I ask if you had the source code is that you could modify the code to call first one programme then the other but the batch script posted by Razor 2.3 should do the job just as well although batch scripts is not something I know much about,.

Stuart



#1
July 31, 2011 at 12:12:00
Do you have the source code for these files?

Stuart


Report •

#2
July 31, 2011 at 14:25:51
Man i am new in this so how do i get the code?
thanks:)

Report •

#3
July 31, 2011 at 14:38:44
Ask the guy who wrote the program for the code.

Failing that, the easiest way would probably be a batch script:

start "" /wait "<program 1>"
"<program 2>"

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
July 31, 2011 at 15:05:35
Guys thats the problem i dont have the source code i wrote both of the programs in two diffrent ways but they both exe files :)

Report •

#5
July 31, 2011 at 15:25:39
✔ Best Answer
If you the programs yourself you must have the source code, even if it is only compiled batch script.

.EXE files are binary files which means they are just a load of numbers, numbers that the CPU can understand. The Source code is what the programmer wrote that humans can understand that is then compiled into an .EXE.

The reason I ask if you had the source code is that you could modify the code to call first one programme then the other but the batch script posted by Razor 2.3 should do the job just as well although batch scripts is not something I know much about,.

Stuart


Report •

#6
July 31, 2011 at 23:53:03
Ok this is the code from The VB program:

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "A" Then

MsgBox("Correct", MsgBoxStyle.Information, "program")
Me.Hide()
Else : MsgBox("Wrong", MsgBoxStyle.Critical, "program")
Me.Close()
End If

End

End Sub


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class

tell me if this what you mean when you tell me source code and thanks for helping me:)


Report •

#7
August 1, 2011 at 03:18:28
That is source code. Looking at it is looks like VB.BET

With VB there is a way of calling one programme from another and have the first one halt till the called programme terminates. Call synchronous execution. Normal using system call celled program execute and the programme calling it also continues to run. The is asynchronous execution which is the default.

Stuart


Report •

#8
August 1, 2011 at 06:12:49
ok thanks:) so can you tell how do i call another program from the first one,is there any way to put the other program inside the first one

Report •

#9
August 1, 2011 at 06:47:09
You can use the Create Process API and the WaitForSingle object APi.

You put this code in the first application which then calls the second which executes, putting the first one on hold the execution is complete,

You might want to read this which describes how to use the STARTUP structure. If you are no tfamilar with using the API it could get a bit complicated in which case the batch script might be the simplest solution.

http://msdn.microsoft.com/en-us/lib...


Public Sub ExecCmd(CmdLine As String)

Dim Proc As PROCESS_INFORMATION
Dim Start As STARTUPINFO
Dim Ret As Boolean

' Initialize the STARTUPINFO structure:
Start.cb = Len(Start)

' Start the shelled application:





Ret = CreateProcessA(0&, CmdLine, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, Start, Proc)
RetValue = Ret



Ret = WaitForSingleObject(Proc.hProcess, INFINITE)
Ret = CloseHandle(Proc.hProcess)


End Sub

Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Declare Function CreateProcessA Lib "kernel32" (ByVal lpApplicationName As Long, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Public Const NORMAL_PRIORITY_CLASS = &H20&
Public Const INFINITE = -1&


Public Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type

Public Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type

This was designed for use with VB6. I am not sure it will work with VB.NET or may need some tweaking to make it work.

Stuart


Report •

#10
August 1, 2011 at 09:46:30
I should point out VB.NET has its own version of the above that doesn't require importing unmanaged code.

EDIT: Case in point:

Module Module1
  Sub Main()
    'Start first process
    Dim processToWaitOn As System.Diagnostics.Process = _
      System.Diagnostics.Process.Start("notepad.exe")

    'Start waiting
    Dim waitForProcess As New System.Threading.ManualResetEvent(False)
    waitForProcess.SafeWaitHandle = _
      New Microsoft.Win32.SafeHandles.SafeWaitHandle(processToWaitOn.Handle, False)
    waitForProcess.WaitOne()

    'Start other process
    System.Diagnostics.Process.Start("calc.exe")
  End Sub
End Module

(Normally in VB.NET, you'd Import the relevant namespaces, and use Option Infer. I didn't to avoid confusion.)
How To Ask Questions The Smart Way


Report •

#11
August 1, 2011 at 13:27:03
thanks for the code but
its to difficult to me to understand it i try to put the code in my program but it does not work for me i just cant understant how to do this :)
so is there way to run the exe from resources without extract it (Like from inside the program so the program will work in other computer without other file)
or if you would like to give other ways to this :)
I appreciate your help:)

Report •

Ask Question