 |
| Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET). |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

November 15th, 2007, 01:15 PM
|
|
Authorized User
|
|
Join Date: Nov 2007
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
running executable with VB6
I am trying to run an external executable file with VB6. I can make it to run, but it doesn't run from the location where it is supposed to. In my form, I asked for input location of certain file folder, then the location for the executable. The executable is then copied to the folder which contains the files. Then I run the exe with shell function, but it keeps running from the original location and not the one where it has been copied. I am quite sure I have the right path executable as I can see them with the debug.print.
Here is my code, can I get some help here, thanks.
Code:
Private Sub Command3_Click()
Dim src As String
Dim des As String
Dim count As Integer
Dim resDes As String
Dim Result As String
Dim i As Integer
Dim runExe As Double
Dim finPath As String
src = seiengFile
des = SDRSFile
'NM: finding the folder that contains the sdrs files. The path is parced to locate
'the last back slash. The location is used as a second argument for Left function to get to the folder.
For i = 0 To Len(des)
resDes = Mid(des, Len(des) - i, 1)
If (resDes = "\") Then
count = Len(des) - i
Exit For
End If
Next i
Result = Left(des, count)
finPath = Result & "SEIENG.exe"
FileCopy src, finPath
Debug.Print "finPath = " & finPath
Debug.Print "Result + executable = " & Result & "SEIENG.exe"
runExe = Shell(finPath, vbMaximizedFocus)
frmSeieng.Hide
End Sub
|
|

November 15th, 2007, 01:54 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
HI there.. how do you know from where is it running???
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
|
|

November 15th, 2007, 03:09 PM
|
|
Authorized User
|
|
Join Date: Nov 2007
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
The executable requires those files to run some process. The interface for the executable shows the path from its running location.
For example, when I submit the button on the form ( that will copy the executable and run it) the interface opens up and shows me the location of the executable where it is being executed.
|
|

November 15th, 2007, 03:13 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
the interface of the program you just copied??
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
|
|

November 15th, 2007, 03:23 PM
|
|
Authorized User
|
|
Join Date: Nov 2007
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
No.
The code I have pasted here is the form I have created. The code runs a shell function(near the end of the form). That parameter of the function takes the path which is the location of the copied executable, and the name of the executable.
When I run the submit button on my farm, the executable runs and shows the its location from where it is running. It should be the same as the path, which is provided as a parameter to the shell function, however, it is running from the location from where it was copied from.
|
|

November 15th, 2007, 03:25 PM
|
|
Authorized User
|
|
Join Date: Nov 2007
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
addendum:
I meant "yes", it is the same executable interface.
|
|

November 15th, 2007, 03:41 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
ok.. the 2 debug line show the same?
maybe this exe is registered and launched always from the original position??
copy demands a time, are you sure that the file exists before you run the shell??
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
|
|

November 15th, 2007, 03:53 PM
|
|
Authorized User
|
|
Join Date: Nov 2007
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
yes, the two debug statements give me the same output.
I am quite sure that when the shell command runs, the file has been copied on the premis that stack will not return the command to the next statement until the previous is finished.
|
|

November 15th, 2007, 03:54 PM
|
|
Authorized User
|
|
Join Date: Nov 2007
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
the executable is not registered as such. That has been developed within the company and has been used here for sometime now. They have been doing this manually, and now we are in a phase of automating various tasks like this one.
|
|

November 15th, 2007, 03:55 PM
|
|
Authorized User
|
|
Join Date: Nov 2007
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
the executable is written in fortran.
|
|
 |