Results 1 to 13 of 13

Thread: Execute EXE file

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2002
    Location
    Malaysia
    Posts
    124

    Execute EXE file

    How do I execute an .exe file using VB code?

  2. #2
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Use Shell function

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Lunatic3
    Use Shell function
    I think Shell and API ways are old stuff to run exe . anyways , here's .NET way
    VB Code:
    1. System.Diagnostics.Process.Start("notepad.exe")
    try it ...

  4. #4
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Thanks Pirate.

    Shell synstax is :

    Public Function Shell( _
    ByVal Pathname As String, _
    Optional ByVal Style As AppWinStyle = AppWinStyle.MinimizedFocus, _
    Optional ByVal Wait As Boolean = False, _
    Optional ByVal Timeout As Integer = -1 _
    ) As Integer

    Is there an easy way to define optional arguments of Shell- Style,Wait and Timeout- for Process.Start ?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 2002
    Location
    Malaysia
    Posts
    124

    exe with arguments?

    i have a arj.exe file
    my command is
    arj a a:test c:test.mdb -va -y
    how do i insert this arguments in the vb code?

  6. #6
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    System.Diagnostics.Process.Start has an overloaded version that takes filename and argument.

    ex:

    Code:
    System.Diagnostics.Process.Start("arj.exe", "-va -y")

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Lunatic3
    Thanks Pirate.

    Shell synstax is :

    Public Function Shell( _
    ByVal Pathname As String, _
    Optional ByVal Style As AppWinStyle = AppWinStyle.MinimizedFocus, _
    Optional ByVal Wait As Boolean = False, _
    Optional ByVal Timeout As Integer = -1 _
    ) As Integer
    Is there an easy way to define optional arguments of Shell- Style,Wait and Timeout- for Process.Start ?
    Isn't this func from VB6 ?I mean API ?

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Nov 2002
    Location
    Malaysia
    Posts
    124
    Originally posted by Athley
    System.Diagnostics.Process.Start has an overloaded version that takes filename and argument.

    ex:

    Code:
    System.Diagnostics.Process.Start("arj.exe", "-va -y")
    I've used this code, but only command prompt opened and file was not copy into the a:

    System.Diagnostics.Process.Start("c:arj.exe", " a a:test c:test.mdb -va -y")

  9. #9
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    Originally posted by chinhow
    I've used this code, but only command prompt opened and file was not copy into the a:

    System.Diagnostics.Process.Start("c:arj.exe", " a a:test c:test.mdb -va -y")
    The argument part of the start method should not include the preceding space. Try...

    Code:
    System.Diagnostics.Process.Start("c:\arj.exe", "a a:test c:\test.mdb -va -y")
    As it is an argument it presumes it should be a space and adds one itself.
    Last edited by Athley; Jan 30th, 2003 at 01:04 PM.

  10. #10
    Member
    Join Date
    Jan 2003
    Posts
    32
    format:

    Shell("C:\program.exe")


    Easy as 123
    Smartbar XP is WAY better then Dashboard. http://www.smartbarxp.com

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Nov 2002
    Location
    Malaysia
    Posts
    124
    Originally posted by Athley
    The argument part of the start method should not include the preceding space. Try...

    Code:
    System.Diagnostics.Process.Start("c:\arj.exe", "a a:test c:\test.mdb -va -y")
    As it is an argument it presumes it should be a space and adds one itself.
    yes, i tried System.Dianostics.Process.Start("C:\arj.exe", "a a:test C:\test.mdb -va -y") BUT it won't treat the latter as the arguments. In other words, the exe is doing nothing but just open the command prompt and close it without execute the file copy.....

  12. #12
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Try this
    VB Code:
    1. Dim p As New Process()
    2. p.StartInfo.FileName = "arj.exe"
    3. p.StartInfo.Arguments = "a a:test c:\test.mdb -va -y"
    4. p.Start()
    Dont gain the world and lose your soul

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Nov 2002
    Location
    Malaysia
    Posts
    124
    Originally posted by DevGrp
    Try this
    VB Code:
    1. Dim p As New Process()
    2. p.StartInfo.FileName = "arj.exe"
    3. p.StartInfo.Arguments = "a a:test c:\test.mdb -va -y"
    4. p.Start()
    Thanks, It's worked!!!!
    But why the command prompt didn't display the progress ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width