Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 15th, 2007, 12:15 PM
Authorized User
 
Join Date: Nov 2007
Location: , , .
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
Default 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
Reply With Quote
  #2 (permalink)  
Old November 15th, 2007, 12:54 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,190
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

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
================================================== =========
Reply With Quote
  #3 (permalink)  
Old November 15th, 2007, 02:09 PM
Authorized User
 
Join Date: Nov 2007
Location: , , .
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
Default

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.

Reply With Quote
  #4 (permalink)  
Old November 15th, 2007, 02:13 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,190
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

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
================================================== =========
Reply With Quote
  #5 (permalink)  
Old November 15th, 2007, 02:23 PM
Authorized User
 
Join Date: Nov 2007
Location: , , .
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
Default

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.

Reply With Quote
  #6 (permalink)  
Old November 15th, 2007, 02:25 PM
Authorized User
 
Join Date: Nov 2007
Location: , , .
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
Default

addendum:
I meant "yes", it is the same executable interface.

Reply With Quote
  #7 (permalink)  
Old November 15th, 2007, 02:41 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,190
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

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
================================================== =========
Reply With Quote
  #8 (permalink)  
Old November 15th, 2007, 02:53 PM
Authorized User
 
Join Date: Nov 2007
Location: , , .
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
Default

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.

Reply With Quote
  #9 (permalink)  
Old November 15th, 2007, 02:54 PM
Authorized User
 
Join Date: Nov 2007
Location: , , .
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
Default

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.

Reply With Quote
  #10 (permalink)  
Old November 15th, 2007, 02:55 PM
Authorized User
 
Join Date: Nov 2007
Location: , , .
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
Default

the executable is written in fortran.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Running executable file Promod333 Visual Basic 2005 Basics 1 September 7th, 2007 10:15 AM
Timed Executable KennethMungwira Beginning VB 6 1 July 28th, 2006 10:55 AM
Executable - From Server KennethMungwira VB.NET 0 July 20th, 2006 02:33 PM
Tracing via executable bmains VB.NET 1 April 29th, 2004 02:41 PM
Running a VB6 app as a service adman Pro VB 6 3 April 6th, 2004 02:21 PM



All times are GMT -4. The time now is 01:14 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.